1

i'm creating a portfolio site where artists can show projects. artists are a category enter image description here

on a project page (from an artist) i want to show the artists other projects as well. this seems simple but i'm not sure how to do this:

// get the category_id   
    {exp:channel:entries channel="projects" status="open" limit="1" orderby="entry_date" sort="asc"}
        {categories show_group="1"}
           // parents from the categories are not artists but artist groups
            {if category_id != "1" AND category_id != "2" AND category_id != "3" AND category_id != "4"}
                <?php $artistid="{category_id}"; ?>
            {/if}
        {/categories}
    {/exp:channel:entries}

// show all titles from the category id (artist id)
    {exp:channel:entries channel="projects" category="<?php echo $artistid ?>" status="open" limit="50" orderby="entry_date" sort="asc" dynamic="off"}
         {title} /
    {/exp:channel:entries}

eg on portfolio/project/test-dave-eerste-van-de-dag, the artist_id is 6 but it doesn't work in the second exp:channel:entries. php is on output. probably it goes wrong with both input and output. there must be an easier way to do this!

1

I would try using an embed to pass through your php variable. So the first half stays the same then:

// show all titles from the category id (artist id)
    {embed="template_group/template_name" cat_id="<?php echo $artistid ?>"}

Then in your embedded template

{exp:channel:entries channel="projects" category="{embed:cat_id}" status="open" limit="50" orderby="entry_date" sort="asc" dynamic="off"}
         {title} /
    {/exp:channel:entries}
2
  • smart! :) (and it works) Nov 12 '13 at 16:13
  • Glad I could help
    – CreateSean
    Nov 12 '13 at 21:16

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.