We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Cookies Plus

Development and Programming

DeeCee's avatar
DeeCee
118 posts
16 years ago
DeeCee's avatar DeeCee

The original thread was getting really long, so I started a new one for my question.

I am trying to build breadcrumbs from cookies (yes, I looked at crumbee, but it assumes that you are going down the url path, and I can bounce all over the place). I built the code in php but 1) every template would have to have php enabled, and 2) I cannot nicely handle my {site_url} when I move from test to production since I cannot embed EE globals in php, correct?.

This is the php code:

<?php
setcookie('link1', 'template_group/template1', time()+(60*60*24*7));
setcookie('name1', 'Description 1', time()+(60*60*24*7));

// I may or maynot have a link2
setcookie('link2', 'template_group/template2/category/cat', time()+(60*60*24*7));
setcookie('name2', 'Description 2', time()+(60*60*24*7));
?>

 <?php
    if (isset($_COOKIE['link1'])) {
           echo "<div id=\"breadcrumbs\">";
        $link1=$_COOKIE['link1'];
        $name1=$_COOKIE['name1'];
    echo "<a href="/cwc/"> Home </a>".
        " / <a href="/cwc/index.php/.$link1"> ". $name1." </a>";
//    ditto for link2
    echo "</div>"
    }  
?>

This is what I tried with cookie_plus: I am not able to get the link or the name (can it only be used in a conditional?)

{exp:cookie_plus:set name="link1" value="template_group/template1" seconds="36000"}
{exp:cookie_plus:set name="name1" value="Description 1" seconds="36000"}
{exp:cookie_plus:set name="link2" value="template_group/template2/category/cat" seconds="36000"}
{exp:cookie_plus:set name="name2" value="Description 2" seconds="36000"}

   <div id="breadcrumbs">
    {exp:cookie_plus:get name="link1" parse="inward"}
    <a href="http://{site_url}index.php"> Home </a>
     / <a href="http://{site_url}{cookie}"> OR?      / <a href="{path={cookie}}"> _    {/exp:cookie_plus:get}_    {exp:cookie_plus:get name="name1"}_        {cookie} </a>             
    {/exp:cookie_plus:get}

   </div>

I would test to see if link2 is set - I may or may not have a link2

Thanks for any suggestions!! (Jun 8 - I updated this post with the html. The escaped characters got removed in the original post)

       
Pascal Kriete's avatar
Pascal Kriete
2,589 posts
16 years ago
Pascal Kriete's avatar Pascal Kriete

This would definitely be better off in a plugin, but I must admit I don’t quite understand what you’re trying to do. It looks like you’re trying to put the last two pages into a the cookie (EE already does this, take a look at the exp_tracker cookie). Seems like this would be a very unpredictable breadcrumb though.

2) I cannot nicely handle my {site_url} when I move from test to production since I cannot embed EE globals in php, correct?.

You can, just as you would anywhere else:

global $PREFS;
echo $PREFS->ini('site_url');
       
DeeCee's avatar
DeeCee
118 posts
16 years ago
DeeCee's avatar DeeCee

Thank you, Pascal. I found the documentation for tracker, and yes, this is what I was looking for. Do you have a suggestion on how I store the ‘nice name’ for the page, ie Home instead of index.php? Again, a page can get called from several template groups/template, so I cannot just follow the url up the string.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.