We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

How to create global category sort ?

Development and Programming

MaxStoun's avatar
MaxStoun
21 posts
15 years ago
MaxStoun's avatar MaxStoun

Good day. I need to create global category sort. For example - I have channels Channel1, Channel2 with category like as City. I want to show to user from City1 entries only with category City1 on all channels pages. City1 I may specify in user profile, for example.

       
Boyink!'s avatar
Boyink!
5,011 posts
15 years ago
Boyink!'s avatar Boyink!

Sorry, your question is hard to understand. Do you need a sort (IE showing categories in the proper order) or categorized content (showing only entries belonging to a specific category)?

       
MaxStoun's avatar
MaxStoun
21 posts
15 years ago
MaxStoun's avatar MaxStoun

Sorry for my English. I need to categorized content

       
Boyink!'s avatar
Boyink!
5,011 posts
15 years ago
Boyink!'s avatar Boyink!

To show categorized content, you need templates that get loaded at category URL’s. The channel entries tags on those templates will self-filter when loaded at a category url.

See this tutorial for working with one template that is loaded with and without category urls.

       
MaxStoun's avatar
MaxStoun
21 posts
15 years ago
MaxStoun's avatar MaxStoun

Ok. Thanks

       
MaxStoun's avatar
MaxStoun
21 posts
15 years ago
MaxStoun's avatar MaxStoun

Can I create a hook on call {exp:channel:entries}? And then modify the contents of the tag {exp:channel:entries} If yes - tell me, please, as it is being implemented.

For example - I intercept call of {exp:channel:entries channel="channel1"} and modify it to {exp:channel:entries channel="channel2"} ?

Thanks a lot.

       
Boyink!'s avatar
Boyink!
5,011 posts
15 years ago
Boyink!'s avatar Boyink!

Why?

       
MaxStoun's avatar
MaxStoun
21 posts
15 years ago
MaxStoun's avatar MaxStoun

Good day. I try get tagdata from {exp:channel:entries ….} and modify it. For example - in template I call {exp:channel:entries channel="channel1" limit="5"}, but in extension I modify call to {exp:channel:entries channel="channel1" limit="10"} I try to use http://eeclub.ru/docs2/development/extension_hooks/module/channel/index.html#channel_entries_tagdata For test I create extension which write to file tagdata, like

function activate_extension()
{    
    $data = array(
        'class'        => __CLASS__,
        'method'    => 'modifyExpChannelTag',
        'hook'        => 'channel_entries_tagdata',
        'settings'    => serialize($this->settings),
        'priority'    => 10,
        'version'    => $this->version,
        'enabled'    => 'y'
    );
        
    $this->EE->db->insert('extensions', $data);
}
    
function disable_extension()
{
    $this->EE->db->where('class', __CLASS__);
    $this->EE->db->delete('extensions');
}

function modifyExpChannelTag($param1, $param2)
{
    $fh = fopen("c:\\test.txt", "a+");  // I'm use windows
    fwrite($fh, var_export($param1,true)); 
    fclose($fh);
    return $param1;
}

In file I expect to see - {exp:channel:entries channel="channel1" limit="5"}, but I see another information (like as parsed page) Where is my mistake ?

       
Boyink!'s avatar
Boyink!
5,011 posts
15 years ago
Boyink!'s avatar Boyink!

You’ve totally lost me, sorry.

What’s your goal here? What content are you trying to display? What’s the purpose of the extension? Why are you not using a category-related EE tag to show categorize content?

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.