1

Is it possible to set the category id in a channel entries tag based on the last segment or by another method so that I don't have to create multiple templates?

I'm trying to get this template to fly.

{embed="_layouts/index"}

{exp:stash:append name="listings"}
        <div class="widget">
            <div class="whead"><h6>Listings</h6></div>
            <div class="shownpars">
                <table cellpadding="0" cellspacing="0" border="0" class="dTable">
                    <thead>
                        <tr>
                            <th>Name<span class="sorting" style="display: block;"></span></th>
                            <th>Location</th>
                            <th>Phone</th>
                            <th>Email</th>
                        </tr>
                    </thead>
                    <tbody>
                        {exp:channel:entries channel="members" category="{category_id}" status="Open" limit="100" disable="category_fields|member_data|pagination|trackbacks" dynamic="no"}
                        <tr>
                            <td>{title}</td>
                            <td>{member_location}</td>
                            <td>{member_phone}</td>
                            <td class="center">{member_email}</td>
                        </tr>
                        {/exp:channel:entries}
                    </tbody>
                </table> 
            </div>
        </div>   
{/exp:stash:append}

{exp:stash:set name="content"}
    {exp:stash:get name="listings"}
{/exp:stash:set}
3

If your url contains the proper category you can use Low's seg2cat plugin to grab the id

category="{segment_xx_category_id}"

http://gotolow.com/addons/low-seg2cat

I'm afk from pc, you may have to tweak parse order but I've used this plugin to great affect many times for this purpose.

2
  • Hi stuart. I'm not sure if my current setup would allow me to do that. Right now I'm using the pages module and using a custom url e.g. example.com/us/fl/miami is there a way to do it like so? – user1267 Mar 31 '13 at 12:25
  • There shouldn't be any problem there. In your example if you wanted the last segment then you'd just use category="{segment_3_category_id}". Where you're using segment_3 to grab the category id. Alternatively you can grab the name and other properties. – Ian Mar 31 '13 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.