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.

Pass Category Name to Single Post

June 11, 2009 4:05pm

Subscribe [2]
  • #16 / Jun 15, 2009 4:52pm

    Mark Bowen

    12637 posts

    I personally think your easiest way to do this would be to use something like the Session Variables Plugin. You said above that you will be doing this sort of thing :

    1 - Visiting a category page.
    2 - Clicking on an entry on that page and
    3 - Viewing that entry.

    If that’s the way you are doing it then using the Session Variables Plugin then you will be able to modify that process ever so slightly to do this instead :

    1 - Visit category page.
    2 - Write the name of the current category to a session variable using the plugin.
    3 - Click on entry on that page.
    4 - View single entry page and spit out the currently saved session variable.

    Hope that helps a bit.

    Best wishes,

    Mark

  • #17 / Jun 15, 2009 5:02pm

    Big Skillet

    364 posts

    Thanks Mark, 

    I didn’t realize there was a plugin for the session variables.  I’ve got it installed and I’m assigning the variable like this:

    {exp:session:set name='category' value='{segment_2}'}

    Now, how do I add that variable to the single post URL?

  • #18 / Jun 15, 2009 5:06pm

    Mark Bowen

    12637 posts

    Hiya,

    There shouldn’t be a need to add the variable to the URL. With the plugin you will just be able to spit out that variable on the next page so no need to add it into the URL as it will still be available to you when you get to the next page. Just place this on the single entry template somewhere :

    {exp:session:get name='category'}

    and you should get spat out what you need. I would advise that perhaps you should use a different name other than category for your session variable just to make sure that there aren’t any conflicts anywhere along the way.

    Best wishes,

    Mark

  • #19 / Jun 15, 2009 5:11pm

    Big Skillet

    364 posts

    Where exactly should I place these tags?  Before the opening <html>, inside?  It’s breaking my page.

  • #20 / Jun 15, 2009 5:17pm

    Big Skillet

    364 posts

    : Cannot send session cookie - headers already sent by (output started at /path.php:14) in pi.session_variables.php on line 48

  • #21 / Jun 15, 2009 5:22pm

    Mark Bowen

    12637 posts

    Where exactly should I place these tags?  Before the opening <html>, inside?  It’s breaking my page.

    I wouldn’t suggest placing them before the HTML tags no. You will need to place the tag that sets the variable somewhere where it can pick up the name of the category you want to set. The one that then fetches / displays the variable you can just place anywhere on the single entry template that you want to show this information.

  • #22 / Jun 15, 2009 5:24pm

    Big Skillet

    364 posts

    Gotcha…. I’m still getting that “session cookie” error though.

  • #23 / Jun 15, 2009 6:35pm

    Mark Bowen

    12637 posts

    Gotcha…. I’m still getting that “session cookie” error though.

    Oops sorry missed that post previously. Does the plugin work though to spit out the variable where you need it?

    If so then perhaps try in another browser without being logged in and see if you still get that error.

    If you do then you might need to get in touch with the developer of that plugin to see why it’s doing that. I must say though that I’ve used that plugin a fair few times now though and never seen that problem so not too sure why you would be getting that.

    Best wishes,

    Mark

  • #24 / Jun 15, 2009 7:04pm

    Big Skillet

    364 posts

    No, it’s not spitting out the information either.  I’ll contact the developer and let you know.

  • #25 / Jun 15, 2009 7:10pm

    Mark Bowen

    12637 posts

    No, it’s not spitting out the information either.  I’ll contact the developer and let you know.

    Hmm weird. I just downloaded it and tried again on a brand new install of ExpressionEngine 1.6.7 and it all seems to work fine so not too sure why it’s not working for you in this case. Hopefully the developer will be able to help you out though.

    Best wishes,

    Mark

  • #26 / Jun 17, 2009 1:05pm

    Big Skillet

    364 posts

    The error with the “Session Variables” plugin ended up being white space in the root path.php file.  Everything works fine now that it’s cleaned up.

    Thank “ender” for first recommending I use session variables, and thanks “Mark” for showing me the plugin.  Thanks “Boyink!” for the recommendations.  I wish we could have gotten that to work.

    Either way, I think the “session variables” may have saved me on this one.  I’m still going to search for a way to include/pass the category in the URL, but at least I have a backup solution that works great.

    Thanks again everybody!

  • #27 / Jun 17, 2009 2:38pm

    Mark Bowen

    12637 posts

    The error with the “Session Variables” plugin ended up being white space in the root path.php file.  Everything works fine now that it’s cleaned up.

    Aha that would have been low down on my list of things to check so glad you got that one sorted.

    Thank “ender” for first recommending I use session variables, and thanks “Mark” for showing me the plugin.

    No problem, any time.

    Either way, I think the “session variables” may have saved me on this one.  I’m still going to search for a way to include/pass the category in the URL, but at least I have a backup solution that works great.

    Thanks again everybody!

    Yep that plugin is great and I use that on loads of sites, really quite a lifesaver that one.

    Glad you have it all working now and hope everything else goes well for you.

    Best wishes,

    Mark

  • #28 / Jun 17, 2009 10:01pm

    Big Skillet

    364 posts

    Ugh, I may have spoke too soon…

    I’m passing the category name variable to the next page and populating the title/data just fine, but it doesn’t work if I try to use next_entry or prev_entry.  Once I’ve entered a category and have chosen a movie in that category, the next_entry and prev_entry to pull movies from that same category.

    {exp:weblog:next_entry category="{exp:session_variables:get name="section"}"}

    is not working… So, the variable route might not work after all.

    Is there not any way to enter a category and say within that category after you choose a post?

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

ExpressionEngine News!

#eecms, #events, #releases