Elegant way / hook to redirect specific category_id to a "landingpage"

Open to all! Ask other shopowners for help.
Post Reply
loop
Contributor
Posts: 253
Joined: Thu Mar 25, 2021 12:26 pm
Phoenix Version:
Has thanked: 7 times
Been thanked: 3 times

Elegant way / hook to redirect specific category_id to a "landingpage"

Post by loop »

Hi All
I need a specific categories_id to redirected to a "new" page. is there a elegant way to do that? (of course i can change the template of index.php and say if($GLOBALS['current_category_id']==123) thenn ....else if ($category_depth == 'nested') { ....
but the question is if there is a better solution....

thanks!


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Elegant way / hook to redirect specific category_id to a "landingpage"

Post by Kofod95 »

Maybe the if in hooks/index and listen to inject_siteStart (I don't remember precisely how it's named)

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Elegant way / hook to redirect specific category_id to a "landingpage"

Post by ecartz »

Code: Select all

class hook_shop_index_landing {

  public function listen_siteWideStart() {
    if ($GLOBALS['current_category_id'] == 123) {
      // redirect
    }
  }

}
loop
Contributor
Posts: 253
Joined: Thu Mar 25, 2021 12:26 pm
Phoenix Version:
Has thanked: 7 times
Been thanked: 3 times

Re: Elegant way / hook to redirect specific category_id to a "landingpage"

Post by loop »

hi ecartz
but does this work with a new content module?
i made a new contentmodule "landing_page" and want that the according content module is loaded instead of index_nested

Code: Select all

 if($GLOBALS['current_category_id'] == 1009){
    echo $GLOBALS['current_category_id'];
?>
    <div class="row">
        <?php echo $oscTemplate->getContent('landing_page'); ?>
    </div>
<?php
  }
does it work thenn with the hook?
loop
Contributor
Posts: 253
Joined: Thu Mar 25, 2021 12:26 pm
Phoenix Version:
Has thanked: 7 times
Been thanked: 3 times

Re: Elegant way / hook to redirect specific category_id to a "landingpage"

Post by loop »

i tried it but it seems it doesnt work like this, as i make not a redirection, i want to include the content :(

Code: Select all

class hook_shop_index_landingpage {

public function listen_siteWideStart() {
    if($GLOBALS['current_category_id'] == 1009){
        ?>
    <div class="row">
        <?php echo $oscTemplate->getContent('landing_page'); ?>
    </div>
<?php
    }
  } 

}
any ideas how to make it like this?


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply