Jump to content

a-ok

Members
  • Posts

    812
  • Joined

  • Last visited

Everything posted by a-ok

  1. I have a bunch of child pages added to a parent section called 'Projects'. These are all being looped out on an overview; for example: <?php $projects = $pages->find('template=project-detail, sort=sort'); ?> <?php foreach ($projects as $project) : ?> These pages will become quite long overtime, but I want to add a 'featured' option to them so they add a class to their element if they are 'featured'. Normally I would just add a tickbox so if it's ticked, it adds the class etc. However, as there are going to be so many pages, looking through them all and maintaining this (as the 'featured' option will change often) will get a bit messy. So, I've created a 'Page field' for the overview, so you can choose which pages you want as 'featured' and remove them easily. However, I'm having an issue working out how I can tell the child page that it has been 'chosen' to be featured, if you see what I mean? How can I, within the $projects loop, cross reference it with the 'featured' page field on the overview, and if they match, add a class? For example <?php $featured = $pages->get('template=home')->featured_items; ?> // Getting an array of the featured items <?php $projects = $pages->find('template=project-detail, sort=sort'); ?> <?php foreach ($projects as $project) : ?> <div class="item <?php if ( $featured->id == $project->id) : ?>featured<?php endif; ?>"></div> // Checking if the featured id contains project->id <?php endforeach; ?> I know the above isn't right, but you get the idea. Can you help at all?
  2. Thanks for the help. So the best way is to do: <?php $tag_colors = explode('|', $project->project_tags); ?> data-color="<?php if (in_array(1025,$tag_colors)) : ?>#ffff00<?php elseif (in_array(1029,$tag_colors)) : ?>#6d8d24<?php elseif (in_array(1030,$tag_colors)) : ?>#3b6e8f<?php elseif (in_array(1031,$tag_colors)) : ?>#00bdff<?php else : ?>#00ff00<?php endif; ?>" This works, so maybe it is. Many thanks.
  3. Thanks for the help. No, I am not iterating over the project tags. I don't really want to. I just want to check them and if it contains an ID (1025, for example) then echo out a hex colour code.
  4. I thought this might've worked: data-color="<?php if (in_array(1025,$project->project_tags)) : ?>#ffff00<?php elseif (in_array(1029,$project->project_tags)) : ?>#6d8d24<?php elseif (in_array(1030,$project->project_tags)) : ?>#3b6e8f<?php elseif (in_array(1031,$project->project_tags)) : ?>#00bdff<?php else : ?>#00ff00<?php endif; ?>" or even: data-color="<?php if ($project->project_tags->has(1025)) : ?>#ffff00<?php elseif ($project->project_tags->has(1029)) : ?>#6d8d24<?php elseif ($project->project_tags->has(1030)) : ?>#3b6e8f<?php elseif ($project->project_tags->has(1031)) : ?>#00bdff<?php else : ?>#00ff00<?php endif; ?>"
  5. Hi folks, This may be a bit of a daft question as it may be more a PHP question than a PW question, but thought I would check. I have some tags set up for each 'project' on my site. All good, and if I echo out $project->project_tags it returns 1025|1074|1026|1027 and obviously I can do a foreach loop on them etc. All good. However, I want to check if a tag exists then assign a colour value to it, for example: data-color="<?php if ($project->project_tags == 1025) : ?>#ff0000<?php endif; ?>" Is there a way to check an array for a value rather than running a foreach loop on it and doing it that way? Thanks, R
  6. Thanks. What is this module? I'm wanting auto add to top and keep manual sorting, which makes sense, really. It's okay, I got it I believe > http://modules.processwire.com/modules/page-tree-add-new-childs-reverse/
  7. Hi there, I'm not sure if this is a setting somewhere, but searching for it returns a thousand results so not sure if it's related to front or back end, but my question is: When I add a new page (child) it automatically adds it to the bottom of the list of children. This seems to be the default setting. How do people feel about this and can you go about changing it? Cheers guys, R
  8. Perfect, @titanium. This worked a treat... didn't think you'd have to do that but hey.
  9. Hi folks, I am using the PageField to find selectable pages and I'm using the 'custom PHP code' field to find my pages. However, the following isn't bringing back any pages: $pages->find('parent=/tags/' . $page->parent->name . '/'); I have tested this code on the page template, and it returns the correct pages but entering this into the custom PHP field returns an empty dropdown field. Any thoughts?
  10. This worked for me in my scenario, but thanks for the others too. Really appreciate the help.
  11. Hi folks, I'm set up a simple next/prev between pages that are loaded in via pjax with the following: <?php if ($page->next->id) : ?> <div class="next-solution-container"> <a data-pjax class="next-solution" href="<?php echo $page->next->url; ?>"><span><?php echo $page->next->title; ?></span></a> </div> <?php endif; ?> This worked great, but I want it now to loop... so if it's the last item, it gets the first item as the next link. I thought the following below would work, but as I am using it on the page template, and thus using $page, I don't think first/last are in use? <?php if ($page == $page->last) : ?> <div class="next-solution-container"> <a data-pjax class="next-solution" href="<?php echo $page->first->url; ?>"><span><?php echo $page->first->title; ?></span></a> </div> <?php else : ?> <div class="next-solution-container"> <a data-pjax class="next-solution" href="<?php echo $page->next->url; ?>"><span><?php echo $page->next->title; ?></span></a> </div> <?php endif; ?> Any thoughts?
  12. Thanks guys, but I need to add multiple points on a map in one go to make a polyline, or polygon.
  13. Is there a Google Maps module out there at all that allows you to add markers (drag and drop, or by address) which outputs a lat/long? I've used something like this on Wordpress but wasn't sure if PW had something similar? Currently I am just using two text fields for editor to add in lat/long coordinates but can get a little tricky. Thanks in advance, R
  14. Hi folks, As the title suggests, is it possible to output the label from a select/dropdown, rather than the value? I am using this module: http://modules.processwire.com/modules/fieldtype-select/ and I am currently outputting the value as follows: <?php echo $project->project_location_type; ?> Thanks in advance, R
  15. Hi folks, I have just pushed up a site from local to live. I have had a dev server for client testing and all was working fine. However, upon upload, on all the pages, fields are missing (even though the content is coming through on the site) and there's weird formatting issues. Please see the screenshot below. There doesn't seem to be any issues in the console or I have tried reuploading all the files but doesn't seem to change a thing. Any thoughts? Thanks, R
  16. I wasn't sure if this was a default quality setting on the module, that was all!
  17. I am using this module but my GIF is coming up with severe quality loss... any ideas?
  18. I find that if I have 'How should this field be displayed in the editor?' selected as 'Always collapsed, requiring a click to open' for a repeater field, and the repeater contains a text area (specifically ckeditor) then more often than not the text area is blank/hidden (if I view source the text is there). Any thoughts?
  19. Referencing https://github.com/defunkt/jquery-pjax/issues/66 I changed the timeout default using $.pjax.defaults.timeout = 3000; And this seemed to have solved the issue.
  20. Thanks for the help. This hasn't made any difference... thanks though. Anyone else?
  21. Hi folks, thanks for all your replies. Here's how I did it. $(document).on('pjax:end', function() { var bodyClass = $('meta[name=body-class]').attr('content'); if (bodyClass !== undefined) { document.body.className = bodyClass; } }); Then on every template which would be within the ajax/pjax container: <meta name="body-class" content="<?php echo $page->name; ?>" /> Thanks, R
  22. Hi folks, I am using AJAX on a site I am building, specifically PJAX, and I have built all this locally and it has all been working great with no problems. Upon pushing this from local to remote the AJAX is failing to retrieve my pages, and thus falling back to the normal page loading. I have had a look at the Network tab in Google devtools to find out more and it looks like the request goes through but the PJAX url call (for example: http://www.juleslister.co.uk/projects/photography?_pjax=%23pjax) is returning as a 301 error. I have a screenshot of the Network issue here: http://i.imgur.com/oC2ZPce.png Any thoughts? Many thanks, R
  23. I'd also like to note that I am using pjax for HTML5 history etc. and it's really great with PW. But perhaps this is actually an application specific issue (https://github.com/defunkt/jquery-pjax/issues/493)
  24. Hi folks, I'm building a fairly simple site using PW but I am also working with AJAX driven content (as noted by @ryan here: https://processwire.com/talk/topic/225-how-to-work-with-ajax-driven-content-in-processwire/) and everything works fine except for the change of body classes per page. So, for example, in the head.inc I have the following: <body class="<?php echo $page->name; ?>"> which is useful as it means I can create page specific styles etc. However, as the head and foot remain constant if an AJAX request is called using the following, for example: <?php if(!$config->ajax) include('./head.inc'); ?> the body class fails to update for obvious reasons. Is there any way round this so the body class is updated per ajax call, if you know what I mean? This may be a global AJAX question and not a PW specific question but thought I would ask all the same. Thanks, R
  25. Thank you so much for the reply, @renobird. Really appreciated. Normally I would opt for the customised admin theme and a separate PW instance for the intranet. This makes sense. But I think there's definite room and desire to have something that has some full scale front-end approach. Simple stuff like posts and profile editing, but enough to make it feel like PW is powering it all without having to access the admin. I did something similar with WP before, and it was a little complicated, but it worked out. It would be great to know if any examples exist on the forums re the full scale front end approach... not really sure where I would start but thanks for all the help. It's nice to know there's a fallback (or better option depending!) if the front end approach can't really be done successfully enough. Thanks again!
×
×
  • Create New...