Jump to content

onjegolders

Members
  • Posts

    1,147
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by onjegolders

  1. Soma, I had a couple of questions... How do you test for if it is set? Is this possible? isset doesn't appear to work, guess that's probably normal though... Also, is it possible to unset it so that people can choose a colour but if they want to return to the default, they can remove all output from the field? I'm using a default background pattern for my site but want to give the user an option to change the header colour. If they want to go back to the pattern, I'm not to sure how to do this without adding a checkbox where they have to tick "I want to use a bg color" and also provide a color.
  2. Thanks to you too Soma, and Diogo and Apeisa and all the other people who make this such a welcoming place for newcomers and help out when we inevitably get stuck. I agree that Ryan sets the tone, he's unfailingly helpful and polite and a bonafide genius at just about any web issue I've ever come across! I do wonder, like a few others, how this place will evolve when it grows, will we still be able to maintain the same "intimate" feeling? (Joss I need your help here with the wording!) I agree with Pete that there will probably need to be moderators for different forums. I love this community! PS: I also think the timing of Soma's post is spot on. It does feel like PW is growing by the day.
  3. Hmmm, think I have it. Got the feeling it was to do with the path part of setcookie, Ryan's tip to have a look in Chrome was a good one, the path was getting set for that page only and just specifying "/" didn't work, I had to add null to the domain part as am on localhost setcookie("InfoBar", $info_bar, time()+3600, "/", null);
  4. Thanks Ryan I didn't know that about viewing cookies in the Inspector. What counts as output? Is that just HTML or a PHP echo? Thanks
  5. Aghhhh, don't you just hate it when for no apparent reason something stops working?! I've literally no idea what's happened but the cookie is now getting emptied randomly on certain page loads. So if content changes, the cookie will reset and the info bar will show, on next page reload it will disappear as the field will once again match the cookie contents but if I then go to another page, the cookie will be an old one and won't match, or it will be empty altogether. I have no idea how this is happening, could it be a caching issue? Though I don't think so as I haven't turned on caching on any pages. My setcookie code is the first thing in my header include and my infobar itself is the first thing inside body. Am pretty at a loose end now, so if anyone could lend a hand it would be MUCH appreciated! Or even a better way to accomplish the same thing? Thanks if you can help! On a small scale test version, outside of PW all seems to work ok. Here is the code I set up: header.inc <?php $info_bar = "Here is my really, really, really important message"; $out = ""; // first check field isn't empty if ($info_bar) { // if cookie doesn't exist, set it if (!isset($_COOKIE["InfoBar"]) && $info_bar) { setcookie("InfoBar", $info_bar, time()+3600); $out = "Field exists and cookie wasn't set so cookie set anew!"; // if it exists but doesn't match the field, reset it } elseif (isset($_COOKIE["InfoBar"]) && $_COOKIE["InfoBar"] !== $info_bar) { setcookie("InfoBar", $info_bar, time()+3600); $out = "Cookie existed but content didn't match, so cookie reset!"; // if it's set and matches, do nothing. } else { $out = "Field has contents but cookie matches so nothing needed to be done"; } } // if field is empty else { $out = "Field has no contents!"; } ?> index.php <?php include("header.inc"); ?> <!DOCTYPE HTML> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="description" content=""> <meta name="description" content=""> <title>Cookies Test</title> <!-- scripts --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <style type="text/css"> * { margin: 0; padding: 0; } #info_bar { width: 100%; text-align: center; padding: 10px 0; background-color: #ecffa1; color: #666; margin-bottom: 80px; } </style> </head> <body> <?php if ($info_bar) { if ($_COOKIE["InfoBar"] !== $info_bar) { ?> <div id="info_bar"> <div class="container"> <?php echo $info_bar; ?> <a class="close" href="javascript:void(0)">x</a> </div> </div> <?php } } ?> <h1>My Cookie Test site!</h1> <h2>Homepage</h2> <h3><?php echo $out; ?></h3> <h3>Field contents: <?php echo $info_bar; ?></h3> <h3>Cookie contents on last reload: <?php echo $_COOKIE["InfoBar"]; ?></h3> <a href="about.php">About</a> <script type="text/javascript"> $(document).ready(function() { $("#info_bar a.close").click(function() { $("#info_bar").slideUp(100); }); }); </script> </body> </html> about.php <?php include("header.inc"); ?> <!DOCTYPE HTML> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="description" content=""> <meta name="description" content=""> <title>Cookies Test</title> <!-- scripts --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <style type="text/css"> * { margin: 0; padding: 0; } #info_bar { width: 100%; text-align: center; padding: 10px 0; background-color: #ecffa1; color: #666; margin-bottom: 80px; } </style> </head> <body> <?php if ($info_bar) { if ($_COOKIE["InfoBar"] !== $info_bar) { ?> <div id="info_bar"> <div class="container"> <?php echo $info_bar; ?> <a class="close" href="javascript:void(0)">x</a> </div> </div> <?php } } ?> <h1>My Cookie Test site!</h1> <h2>About page</h2> <h3><?php echo $out; ?></h3> <h3>Field contents: <?php echo $info_bar; ?></h3> <h3>Cookie contents on last reload: <?php echo $_COOKIE["InfoBar"]; ?></h3> <a href="index.php">Homepage</a> <script type="text/javascript"> $(document).ready(function() { $("#info_bar a.close").click(function() { $("#info_bar").slideUp(100); }); }); </script> </body> </html> I made two different pages just in case it was a problem when going from one page to the next but the code seems to work fine.
  6. This looks absolutely fantastic Michael. Will you be releasing this to the big bad world when you're happy with it? It really looks like a great workflow for the editor!
  7. Hi again Soma, thanks so much for this module which saves me loads of time. Do you have any tips for using it with a select/option menu for mobile. I can't seem to get it to display correctly. Thanks!
  8. Hiya Ryan, not getting any JS errors, this is the link for the second window http://localhost/pw_template/admin/page/image-crop/?filename=20121012_101025.jpg&prefix=full&width=1200&height=%20380&pages_id=1&field=image&modal=1 Moving it out of the tab doesn't have any effect, can only think that the file isn't getting set until page save?
  9. Definitely this data can be be used front end too and having everything page based, I've learned (from using PW) is so much more flexible. For me, it's purely a CSS thing, they're all pages but it helps me distinguish between them. Perhaps something that gives us the power to sort them (like you did with fields - which is brilliantly simple). Or just some CSS hooks for us to style ourselves.
  10. Ryan, that's fantastic, thanks! Out of interest, where would you store that in a normal site? Just above output or in the header include. Suppose it depends?
  11. You and me both! I think it was probably me reloading the page and without seeing the words I later created, failing to understand why the logic wasn't working and probably fiddling rather than going through it properly!
  12. Thanks Adam! Any tips on how to implement this, I seem to be getting an error: Parse error: syntax error, unexpected T_SWITCH, expecting T_STRING But then I probably haven't understood how to use it
  13. Ryan, you make some excellent points but I share a lot of Joe's feelings about making some distinction between front-end pages and pages for storing data. This may be using the "hidden" attribute. It may just be being able to manipulate the CSS somewhat which I did for one site using native PW CSS classes. I added margin to the first "data" page and styled it slightly differently. I think thought there may be no separation between these types of pages for us lot, I think there still is for the average end user. I'll check out mindplay's module, looks interesting
  14. Hmm nope, definitely published. It's a Cropimage field in a repeater in a fieldset Tab on the latest dev version. Not sure else what could affect it?
  15. This is something I need to do a lot when I'm using columned layouts, it's not the sort of thing you always want to rely on CSS3 or JS for. Don't know if it's possible or even desirable but I did used to like the "switch" class available in ExpressionEngine. Would be something like: <div class="switch{left|centre|right}"></div> And it would just loop through them. Was just a useful function to avoid having to set counters and use modulus which I always end up fighting with. http://ellislab.com/expressionengine/user-guide/modules/channel/channel_entries.html#switch
  16. I did what I should always do when I have a problem like this: strip everything back, I created a new mamp site folder with simple PHP and echoed out words to help me understand what was going on on each page reload. Then I adapted it to my PW installation, all seems OK now. The putting it into words thing is surprisingly handy - helps me understand much better! At top: <?php $settings = $pages->get("template=settings"); $info_bar = $settings->info_bar; $out = ""; if ($info_bar) { if (!isset($input->cookie->InfoBar) && $info_bar) { setcookie("InfoBar", $info_bar, time()+3600*24*30); $out = "Field exists and cookie wasn't set so cookie set anew!"; } elseif (isset($input->cookie->InfoBar) && $input->cookie->InfoBar !== $info_bar) { setcookie("InfoBar", $info_bar, time()+3600*24*30); $out = "Cookie existed but content didn't match, so cookie reset!"; } else { $out = "Field has contents but cookie matches so nothing needed to be done"; } } else { $out = "Field is empty!"; } ?> At output: <?php if ($settings->info_bar && $input->cookie->InfoBar) { if ($input->cookie->InfoBar !== $settings->info_bar) { ?> <div id="info_bar"> <div class="container"> <?php echo $settings->info_bar; ?> <a class="close" href="javascript:void(0)">x</a> </div> </div> <?php } } ?> May help people out if they're stuck too
  17. Thanks Ryan that's sorted it. Am having another (sorry ) issue thought it could just be related to the crop module (and maybe I should post there?) If I try and edit the thumbnail before page save then I get an "invalid file" error. If I save the page and then edit the thumbnail, it all seems to work. I don't remember it working this way before, but may be wrong.
  18. I actually tried with $_COOKIE too. The cookie sets OK but then I'm not sure why but after a couple of pages, the bar reappears as for some reason the cookie has been reset. I'm on localhost but not sure whether that's an issue?
  19. Thanks Ryan, I haven't turned any caching on, unless it's on be default? I'm a bit confused as the cookie seems to set then at some point get reset to nothing? I'm not sure where each part of the cookie needs to get checked or why it's resetting when my if condition seems logical enough. If I don't have caching on, would it be best to set them in PHP? Any idea where I'm going wrong with my code? Sorry, just pulling my hair out a bit, all I want to do is to check whether their cookie if they have already had it set, matches the field and if not set it. Thanks again, and congrats on the award!
  20. I'm trying to simplify things somewhat but: Do you want many different views of the same content? -- If so, there really is nothing stopping you from using mysite.com/article/full and mysite.com/article/brief and then using urlSegments to output them. You'd just set some links to the different urls.
  21. ADB It sounds exactly like you just want to use different templates. Your page with three columns would be "three_columns.php" Your page with two columns would be "two_columns.php" Then in your text editor, create the different templates displaying it how you like. So when adding a new page, the client can choose how they want to show the content. I use it for full pages and pages with sidebar. The client can choose which template they want to use for their new page. You can also limit which templates can be used and where under the "Family" tab of Setup->Templates->Template_Name
  22. Actually, it turns out after a while, randomly some pages will start showing the info bar again. It was well within the cookie timeframe which I changed to 30 days. But I couldn't figure out which pages were triggering the infobar to show up again. I'm now trying with At the top: <?php $settings = $pages->get("template=settings"); if ($settings->info_bar && $input->cookie->InfoBar == "") { setcookie("InfoBar", $settings->info_bar, time()+3600*24*30); } ?> To output: <?php if ($settings->info_bar) { ?> <?php if ($input->cookie->InfoBar == $settings->info_bar) { // do nothing } else { ?> <div id="info_bar"> <div class="container"> <?php echo $settings->info_bar; ?> <a class="close" href="javascript:void(0)">x</a> </div> </div> <?php } ?> <?php } ?> But for some reason, the infobar keeps re-appearing. Any ideas?
×
×
  • Create New...