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.

Category URL in an entry link

July 14, 2007 10:44am

Subscribe [2]
  • #1 / Jul 14, 2007 10:44am

    emagine media

    65 posts

    I have a simple window on my front page that will display featured items, when I designate this from my status in my entry. Simple enough.

    The tricky bit is I need to make sure the category changes in the url/link to the details of this, because the entries can be from 1 of 4 different categories.

    The link is:

    _     <a href=“index.php/emaginemedia/cat/{category_url_title}/{url_title}” title=“read more about the {title} project”>{news_image}
    {/categories}

    And it doesn’t give me what I want. Here is the full code that places the category url name above my link, useless to me if I cant generate a dynamic link…

    {if '{segment_3}’ == ‘’}
    {exp:weblog:entries weblog="folio" limit="1" orderby="date" sort="desc" status="featured"}
    <div id=“main_image”>
    {categories}
    {category_url_title}
    {/categories}
      {path="SITE_INDEX/"}
          {news_image}
    </div>

    <div id=“heading_bar”>

    feature: {title}

    </div>
    {/exp:weblog:entries}
    {/if}

    I am noob at this so far, so any and all advice/help would be greatly appreciated.

  • #2 / Jul 15, 2007 12:36pm

    Robin Sowell

    13255 posts

    First- I really try to avoid changing the standard single entry page url structure like that.  If I have extra segments I want to add on, I do it on the end of the url rather than before the url title.  It saves a lot of hassle with other tags you may be using on a single entry page.

    That said- you’re running into an issue because the category variables aren’t available outside of the categories variable pair.  So- if you create the link INSIDE that variable pair?  It will work like you want.  (Or you could use php parsing on output to do it.  Or the Reeposition plugin if you need to move the content around.)

    But for the basics:

    <div id="main_image">
    {categories}
    {category_url_title}
    
    {path="SITE_INDEX/"}
    <a href="http://index.php/emaginemedia/cat/{category_url_title}/{url_title}" title="read more about the {title} project">{news_image}</a>
    {/categories}
    </div>

    Does that get you closer to what you need?

  • #3 / Jul 16, 2007 9:24am

    emagine media

    65 posts

    I changed things to this:

    {exp:weblog:entries weblog="myweblog" limit="1" orderby="date" sort="desc" status="featured"}
    {categories}
    {category_url_title}
    {url_title}
    {news_image}
    {news_image}</p>
    {/categories}
    {/exp:weblog:entries}


    And the only thing that shows up correctly within the categories tag is the {category_url_title} my entries information doesn’t appear within the tags, so the image and the link don’t show up as intended. Does the entries information not display within the categories tags? Or is there some work-around to getting it in there?

    Thanks for the info.

  • #4 / Jul 16, 2007 10:01am

    Robin Sowell

    13255 posts

    It may be a build issue- what build (not version) of EE are you running?  It will be in the footer of the control panel.  I tested on the current build and it worked, but it wouldn’t have in the past.

  • #5 / Jul 16, 2007 11:44am

    Reese Spykerman

    41 posts

    Hi Rob,
    I’m on build 20070622.

    I’m trying this code: (note, I don’t have a limit of 1 on the weblog entries tag. But it seems like that shouldn’t matter)

    {exp:weblog:entries weblog="writing" disable="trackbacks|comments|pagination|member_data" rdf="off"}
    {categories}
    <a href="http://chapter/{url_title}/{category_id}" title="read a Chapter">Read a Chapter</a>
    {/categories}

    And I’m getting a similar issue as emagine up there. My url output looks like:

    <a href="http://www.sitename.com/index.php/writing/category/chapter/7">http://www.sitename.com/index.php/writing/category/chapter/7</a>

    and I’m looking for an output like:

    <a href="http://www.sitename.com/index.php/writing/category/chapter/name_of_entry_title_here/7">http://www.sitename.com/index.php/writing/category/chapter/name_of_entry_title_here/7</a>

    so that I can pass conditionals in my single page template like if segment_5 == 7, do this. But I need to have the entry title in the url, too 😊

    Thanks!

  • #6 / Jul 16, 2007 12:08pm

    Robin Sowell

    13255 posts

    I’m on Build:  20070627- try:

    {exp:weblog:entries limit="5" disable="trackbacks|comments|pagination|member_data" rdf="off"}
    {categories}
    <a href="http://chapter/{url_title}/{category_id}" title="read a Chapter">{title}</a>
    
    {/categories} 
    {/exp:weblog:entries}

    And it outputs:

    <a href="http://chapter/encoding_test/8" title="read a Chapter">Encoding test</a>
    
    <a href="http://chapter/encoding_test/10" title="read a Chapter">Encoding test</a>
    
    <a href="http://chapter/encoding_test/12" title="read a Chapter">Encoding test</a>
     
    <a href="http://chapter/scripting_for_ee_tip_1/1" title="read a Chapter">Scripting for EE- Tip #1</a>
    

    That’s correct- ‘Encoding Test’ shows up 3 times because it’s got three categories assigned.  But that’s what it’s supposed to do.  url_title and category_id are both in there dynamically generated.

    Version issue?  Or am I off on something?

  • #7 / Jul 16, 2007 12:20pm

    Reese Spykerman

    41 posts

    Let me update my version and see if that helps 😊

    edit: hurrah! updating to latest build did the trick. Thanks Robin!

  • #8 / Jul 16, 2007 12:39pm

    Reese Spykerman

    41 posts

    OK, one more follow up. In one of your examples above, you used:

    {path="SITE_INDEX/"}

    I wonder if I might need that so that my outputed url looks like this:

    <a href="http://www.sitename.com/index.php/writing/chapter/name_of_entry_title_here/7">http://www.sitename.com/index.php/writing/chapter/name_of_entry_title_here/7</a>

    Instead of this:

    <a href="http://www.sitename.com/index.php/writing/category/chapter/name_of_entry_title_here/7">http://www.sitename.com/index.php/writing/category/chapter/name_of_entry_title_here/7</a>

    (Note in the second one there’s the existence of the “category” template). The template that this url is coming from is a category template. So we’re on this page:
    http://www.sitename.com/index.php/writing/category/C8

    And I’m sure that’s why “category” is being added to the url path above, since we’re “on” the category template. But is there an easy way for me to remove “category” from the url path or should I do a “find and replace” plugin on it?

  • #9 / Jul 16, 2007 1:15pm

    emagine media

    65 posts

    Build:  20070622

    On a side note, I uploaded all of the files in the newest version to the site, not realising that my config file needs to be preserved, and now I have a ‘the system does not seem to be installed’ message. I think I might cry…

    Is there any way to recreate a config file that would ape my previous installation or am I SOL?

  • #10 / Jul 16, 2007 1:45pm

    emagine media

    65 posts

    Yep went about it completely the wrong way, and managed to not take a copy of my config.php or my path.php file and overwrote all of my files via FTP. The databse is still intact, and I can see a login form, but when I try and login with my old settings, I get:

    index.php?S=0&C=login&M=auth

    and a blank page.

    I am happy to know that this is on a sandbox site, but sucks to have to start over from scratch. Guess I will only do this once ever…

    {expletives edited out to protect the innocent}

  • #11 / Jul 16, 2007 1:56pm

    Robin Sowell

    13255 posts

    Hm- think you could manually rebuild the config pretty easy- most of it has moved to the db by now.  The wiki has a sample file- try grabbing it, edit to fit your config, upload and chmod.  Don’t think it will be too painful.

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

ExpressionEngine News!

#eecms, #events, #releases