ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How to Link to First Entry in First Subcategory from Category Page?

June 21, 2012 9:42pm

Subscribe [2]
  • #16 / Jul 06, 2012 12:26pm

    Shane Eckert

    7174 posts

    Hey msmith29063,

    Thanks for letting us know.

    Is there anything else I can help with?

    Cheers,

  • #17 / Jul 21, 2012 6:39pm

    msmith29063

    75 posts

    The Child Categories add-on won’t work. Too many limitations I think.

    I’m trying to work it out with a query now. Here’s an example of what I’m trying to do in the embed:

    {exp:channel:entries channel="vessels" category="{exp:query sql='SELECT cat_id AS subcat_id FROM exp_categories WHERE parent_id = {embed:category_id} ORDER BY cat_name LIMIT 1'}{subcat_id}{if no_results}{embed:category_id}{/if}{/exp:query}" orderby="vessel_order" sort="asc" limit="1" dynamic="no"}
    <a href="http://{title_permalink=%27vessels/view%27}/" title="{embed:category_name}">{embed:category_image}__{embed:category_name}</a>
    
    <small>{exp:query sql="SELECT count(exp_category_posts.entry_id) AS post_count FROM exp_category_posts WHERE exp_category_posts.cat_id = {embed:category_id}"}{post_count}{/exp:query} vessels</small>
    {/exp:channel:entries}

    Or this:

    {exp:query sql="SELECT cat_id AS subcat_id FROM exp_categories WHERE parent_id = {embed:category_id} ORDER BY cat_name LIMIT 1"}
    {exp:channel:entries channel="vessels" category="{subcat_id}" orderby="vessel_order" sort="asc" limit="1" dynamic="no"}
    <a href="http://{title_permalink=%27vessels/view%27}/" title="{embed:category_name}">{embed:category_image}__{embed:category_name}</a>
    
    <small>{exp:query sql="SELECT count(exp_category_posts.entry_id) AS post_count FROM exp_category_posts WHERE exp_category_posts.cat_id = {embed:category_id}"}{post_count}{/exp:query} vessels</small>
    {/exp:channel:entries}
    {if no_results}
    {exp:channel:entries channel="vessels" category="{embed:category_id}" orderby="vessel_order" sort="asc" limit="1" dynamic="no"}
    <a href="http://{title_permalink=%27vessels/view%27}/" title="{embed:category_name}">{embed:category_image}__{embed:category_name}</a>
    
    <small>{exp:query sql="SELECT count(exp_category_posts.entry_id) AS post_count FROM exp_category_posts WHERE exp_category_posts.cat_id = {embed:category_id}"}{post_count}{/exp:query} vessels</small>
    {/exp:channel:entries}
    {/if}
    {/exp:query}

    Obviously, these won’t work. But this is what I’m trying to do. Any recommendations?

    Thank you.

  • #18 / Jul 23, 2012 4:57pm

    Dan Decker

    7338 posts

    Hey Mathew,

    I’m sorry the add-on didn’t cut the mustard.

    Code sample one won’t work at all. You can’t put module (Query) tags in as parameters, ExpressionEngine’s Parse Order won’t dig it.

    On sample 2, any time you have module (Query/Entries/Query) tags nested, you are likely to have trouble.

    The step would be query->result->embed and so on until you have your result you’re after.

    What I’d really like to do is get into your install and play with this to see if I can’t get a solution for you. You cool with that?

    Be on the lookout for an email from me.

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases