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 make dynamic anchor links

June 12, 2012 9:34am

Subscribe [2]
  • #1 / Jun 12, 2012 9:34am

    Stoelting

    99 posts

    This may be a part EE and part CSS question.

    On the index page of a template group (customer_support), I want to create links to categories that appear on another page in the same template group. On the index template I am using the following:

    {exp:channel:category_archive channel="channel_name1" style="linear"}
        {categories}
            <h2>{category_name}</h2>
    <p>    {/categories}<br />
    {/exp:channel:category_archive}

    On the “downloads” template I am using the following:

    {exp:channel:entries channel="{channel_name1}" category="1" limit="1"}
     {categories}
     <h2>{category_name}</h2>
    <p> {/categories}<br />
    {/exp:channel:entries}</p>
    
    <p>{exp:channel:entries channel="{channel_name1}" category="1"}<br />
     {download_description}<br />
    {/exp:channel:entries}</p>
    
    <p>{exp:channel:entries channel="{channel_name1}" category="2" limit="1"}<br />
     {categories}<br /></p><h2>{category_name}</h2>
    <p> {/categories}<br />
    {/exp:channel:entries}</p>
    
    <p>{exp:channel:entries channel="{channel_name1}" category="2"}<br />
     {download_description}<br />
    {/exp:channel:entries}

    Because of the number of entries in category 1, category 2 and its entries may be out of sight down the page.

    How do I set an anchor ID to each category_name on the “downloads” template and a link to that anchor ID in the index template? It seems like the anchor should use the category ID, since it is unique. But I haven’t figured out how to configure it.

  • #2 / Jun 13, 2012 12:56pm

    Shane Eckert

    7174 posts

    Hey

    Thank you for posting your question here on the ExpressionEngine forums.

    Please give this a try.

    {exp:channel:entries channel="blog" limit="1"}
     {categories}
     <h2><a href="#{category_name}">{category_name}</h2>
    <p> {/categories}<br />
    {/exp:channel:entries}

    Or

    {exp:channel:entries channel="blog" limit="1"}
     {categories}
     <h2><a name="{category_name}">{category_name}</h2>
    <p> {/categories}<br />
    {/exp:channel:entries}

    Depending on what you need.

    Cheers,

     

  • #3 / Jul 09, 2012 10:41am

    Stoelting

    99 posts

    Thanks for your help. I was able to get your second version to work.

  • #4 / Jul 09, 2012 12:46pm

    Shane Eckert

    7174 posts

    Hey Stoelting,

    Awesome! Glad to hear it!!

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases