Link to a specific entry id within a category? (its actually more complicated than that)
Posted: 02 September 2008 03:33 PM   [ Ignore ]  
Summer Student
Total Posts:  4
Joined  06-15-2008

We are developing a store for an antique shop, each product is a weblog entry in a weblog named products.
The weblog has a category group called item_categories, which contains the categories for each product.. So if they are uploading a chair, it goes into the category of “seating”, etc…

So if the user of the site were here: http://mayfairantiquedealers.com/collection
and clicked on “tables and desks” one would see all of the items under tables, and desks.

Here I am linking to the individual items in a template called “item_view”. And this is where I am having a problem. If I use this as the link to the items:
<a href=”{path=collection/item_view/{entry_id}}”></a>

The link works and I go to the correct item based on its entry id… But I loose the category.

This is what I am trying: And I really don’t see why it isn’t working…

<a href=”{path=collection/item_view/{categories}/category/{category_url_title}/{/categories}/{entry_id}}”></a>

The category is being displayed, but the entry_id is ignored, it just links to the first item in that category.

I believe I have all of my weblog preferences set correctly. This is the bit of code in the template: item_view:

<div id="inventoryView">
    
    
{exp:weblog:entries weblog="products" limit="1" dynamic="on"}
    
    


    
<h2>{title}</h2>

    
    
    
            
        
        
        
        <
div id="inventoryItem"><!-- shows one item -->
        
            <
div class="fullitem">
            
                
{exp:imgsizer:size src="{item_image}" height="600" alt="{title}"}
                
                
                
                {if dimensions}

            
            
<p id="dimensions">{dimensions}</p>

                
{/if}
                
                
<a href="{path=locations}">{store_location}</>
                
                
                
                
{/exp:weblog:entries}
                
                
            
            
</div><!-- end this item -->
            
                        
            <
div id="paginationControls">
            
            </
div><!-- end paginationControls -->
        
        </
div><!-- end inventoryBrowser -->
    
    </
div><!-- end inventoryView -->

Is there a way to get the category url title to be displayed in the URL along with the entry id? Reason for this, is that I am using jQuery to change the class of the category navigation and add a “current class” which makes the <li> background white when location.href matches a js variable called current_page…

Profile
 
 
Posted: 02 September 2008 08:31 PM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRank
Total Posts:  1994
Joined  05-07-2007

Forkbomb Studios:

Before we start, have you by chance read over Lisa’s Importance of Semantics series, as well as Understanding URL’s in the docs?  I think you might be making this a little more difficult on yourself than it needs to be, and there could be an easier solution to accomplish what you want.

Regards,

-greg

 Signature 
Profile
MSG
 
 
Posted: 03 September 2008 12:52 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  4
Joined  06-15-2008

Thanks,

I just replaced the location.href with {categories}{category_url_title}{/categories} in the jquery script and acheived the results I wanted.
However after reading “the importance of semantics” and “understanding Urls” I’m still a bit foggy on why the entry_id cannot be referenced with a category in the URL, and what I need to re-arrange to create a url structure that includes the category url title and the entry id.
www.something.com/products/product_view/reserve word/category_url_title/entry_id/

l’ll try reading over the documents again to see if I can come to that “Oh i get it now” moment. Until then, I’m happy with the way this is working.. I understand why it works this way when directly linking to the entry_id. I just don’t understand why it dosen’t work the other way when including the category… Its displaying the item correctly, I just haven’t grasped why I can’t get that to show in my URL….

Profile
 
 
Posted: 10 September 2008 10:42 AM   [ Ignore ]   [ # 3 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23522
Joined  05-20-2002

It’s not so much that you can’t get that url structure if you really want to- with EE there is almost always a workaround.  However, if you don’t use the standard structure, you tend to make more work for yourself.  If you have a choice in the matter, it’s always best to go with the default url structure. 

So in the above- I’d go without the cat url in the individual entries.  And if you need to show the category information anyway?  It’s easy to do- you can just use the {categories} tags w/in the weblog tag to access all the cat info associated with that entry.

Hope it’s all making a bit more sense to you.  Mostly, it just takes a little practice and experimentation.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64912 Total Logged-in Users: 24
Total Topics: 81864 Total Anonymous Users: 18
Total Replies: 440101 Total Guests: 177
Total Posts: 521965    
Members ( View Memberlist )
Newest Members:  bjmohrAqua193Bios Elementmjpoteetguimogranwelshmrcfthenetmonkeybenekwhobutsb