Jump to content

Peter Knight

Members
  • Posts

    1,377
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by Peter Knight

  1. I have it working - thanks again @ottogal Eventually I stripped back everything and started again with this foreach($page->children as $category) { echo "... "; foreach($category->children as $prod) { echo "
  2. I have a new challenge - outputting the grandchild pages of 3 children (simple enough) but confine the display of each grandchild under it's parent heading. Will try explain... My tree looks like this: Foods (where I want to mirror the structure below in a table) - Fruit (Child of Foods and Level 2 Parent) - - Apple - - Banana - - Orange - Vegetable (Child of Foods and Level 2 Parent) - - Carrot - - Potato - - Cauliflower - Meats (Child of Foods and Level 2 Parent) - - Beef - - Pork - - Chicken Lets say "Foods" is the parent. Fruit, Veg and Meat are children. Apple, Bananna etc are grand children I have the Foods template working to an extent but it's doing the following. IE it's Fruit - - Apple - - Banana - - Orange - - Carrot - - Potato - - Cauliflower - - Beef - - Pork - - Chicken Vegetable - - Apple - - Bananna - - Orange - - Carrot - - Potato - - Cauliflower - - Beef - - Pork - - Chicken Meats - - Apple - - Bananna - - Orange - - Carrot - - Potato - - Cauliflower - - Beef - - Pork - - Chicken This is my effort so far. <?php // the children of this page $products = $page->children(); foreach ($products as $prod){ // Create a table for each child page echo" <div> <div class='prod-ov-wrapper'> <div class='prod-ov-text'> {$prod->title} <table class='uk-table uk-table-divider' border=1> <thead> <tr> <th>Part No.</th> <th>Length</th> <th>Break Force</th> <th>Width</th> <th>Colour</th> </tr> </thead> <tbody> "; // populate the table with details of the children of each child $proditem = $page->find("parent=$page->children, template=product"); foreach ($proditem as $prodDetail){ echo" <tr> <td>{$prodDetail->prod_partNo}</td> <td>{$prodDetail->prod_length}</td> <td>{$prodDetail->prod_breakForce}</td> <td>{$prodDetail->prod_width}</td> <td>{$prodDetail->title}</td> </tr> ";} echo" </tbody> </table> </div> </div> </div> ";} ?> I've tried a couple of things over the last few hours and just can't quite understand the API call I need at $proditem = $page->find("parent=$page->children, template=product"); foreach ($proditem as $prodDetail){ echo" is there a way to do this? I suspect I am close but need to add another variable in there?
  3. That what I thought but it was throwing an error. :-/
  4. Thanks @ottogal Picking my way through this but that makes sense. I've never really set a conditional that far up the php script but looking around the forums, this seems to be correct. <?php $products = $page->children(); foreach ($products as $prod){ // Check that images field is poulated if ($prod->images) { //Create variable from first image in field $image = $prod->images->first();} echo" <div > <div class='prod-ov-wrapper'>"; // Check that images field is poulated if($prod->images) echo " <a href='$prod->url'> <img src='{$image->height(160)->url}' class='prod-preview'> </a>"; echo" <div class='prod-ov-text'> <strong>Part No:</strong>{$prod->title} <br/> {$prod->prod_summary} <a href='$prod->url' class='uk-icon-button' uk-icon='icon: chevron-right'></a> </div> </div> </div> ";} ?> I'm wondering though if I'm being a little verbose. I am checking twice if the image field is populated and I have a feeling I could / should only need to do this once?
  5. I have a page that's throwing an error because some of the pages in the for each loop don't have an image The docs say it's wise to check that an image has content and only then try to output something. I thought the following would work with the if($image) below. $products = $page->children(); foreach ($products as $prod){ $image = $prod->images->first(); echo" <div > <div class='prod-ov-wrapper'>"; if($image) echo " <a href='$prod->url'> <img src='{$image->height(160)->url}' class='prod-preview'> </a>"; echo" <div class='prod-ov-text'> <strong>Part No:</strong>{$prod->title} <br/> {$prod->prod_summary} <a href='$prod->url' class='uk-icon-button' uk-icon='icon: chevron-right'></a> </div> </div> </div> ";} What am I overlooking here? Thanks
  6. Interesting read and I'll bring it up with the site owners. This is actually a port from another CMS to Processwire (wohoo). The original site already uses a flag system and language names in local format so I have to stick with that.
  7. Hi @Dinodog Hope you get sorted soon. BTW There's a ProcessWire Developer Directory here: http://directory.processwire.com/ which lists some of the member available for hire. Might be a good future reference. Glad to hear you haven't moved to WordPress. Security nightmare to say the least and a world of pain
  8. I don't know if this answers your question but here's the post i mentioned Essentially I just used this part if($user->language->name == 'french') echo "and pdf_file is the French version.";
  9. I have a dropdown menu which displays a list of languages installed on my site. Id like to add some country flags to the menu list items and the simplest way would be to add an image field to the languages template which is installed in the settings branch. However it seems like this system template won't accept new fields but isn't locked. Is there a way to extend this template to accept new fields? P
  10. You mean via the API? I wanted the same thing over the weekend and found a post where Ryan provided some simple instructions. Don't have it to hand but will in the morning. It was something very simple along the lines of if $language == 'french' ; echo {}
  11. Hi @Zeka That's a huge help. Thanks for the information particularly the image and file fields.
  12. Started my first demo multilingual site last night and I'm really pleased with the ease of setup. I had a 1 page demo with 5 languages and a language switcher and menu running relatively quickly. Before I get too far down the road, I thought I'd ask some of you more experienced multilingual devs what I should be aware of? Off the top of my head... Do any multi-lingual SEO modules exist or should I build my own fields here? I normally use MarkupSEO but not sure yet if it supports multi-lingual. Are any of the Pro fields NOT multilingual? I'm using a single tree with language options as tabs on each field. Is this a better method than having a separate tree for each language? Are image Description fields multilingual? Anything else I should be aware of? For example I read recently that web forms using FormBuilder should be built separately for each language. That's not a huge deal but a good example of something I hadn't anticipated. Cheers P
  13. Hey @Chris Falkenstein i recall an extra that does exactly that released about 2 years ago. Did you look in the Modules directory?
  14. Used to love this app when I was a Windows user. Great to see it mentioned. Often asked the guys to create a Mac version.
  15. Hi guys I have a PW API call which normally outputs all pages as follows <?php if ($page->Related_Downloads->count()) { echo " <ul class='uk-tab' data-uk-tab> <li class='uk-active'><a href='#'><strong>Download</strong></a></li> </ul>"; echo " <div class=' side-promo '>"; foreach($page->Related_Downloads as $download) { $thumb = $download->images->first(); echo " <div class='download-wrapper'> <div class='download-thumb'> <a href='{$download->file->first()->url}' target='_blank' ><img src='{$thumb->url}' class='download-img'></a> </div> <div class='download-info'> <strong>{$download->title}</strong> <br/> {$download->summary} <br/> <a href='{$download->file->first()->url}' class='uk-button uk-button-primary'>Download</a> </div> <br clear='all'> </div> " ;} echo "</div>"; } ?> if I just want to get the very first page that matches my foreach, why does following throw an error? foreach($page->first()->Related_Downloads as $download) {
  16. Just a suggestion but it'd be really useful if there was a Description field available when creating a HannaCode. I like to keep my HC names short and choppy and a description would greatly help users later on establishing what the HC is for or does a Description column on the HannaCode overview page too pulling in above Description It would also be great to be able to see a list of pages where HCs are used within RTEs or templates but that (for me) isn't such a biggie.
  17. Off the top of my head ... 1. Is pagination enabled on that template? 2.
  18. Thanks Ryan Will try that laters. Just backing up everything for the moment and relieved to have it back. Appreciate the advice though.
  19. Thanks @kongondo I tried that in tandem with switching to 5.6.30 and something worked. Site back online now. On a side note, I'm not sure why the site crapped out and threw an upgrade warning when I wasn't upgrading. Ah well.
  20. Just tried installing a Module (AutoSmush) on one of my sites and am now getting following error It was a 3.0.21 site running on PHP 7.0.18 Any tips? I can't find any references to this error online. Cheers
  21. That's it @Robin S. Thanks. I previously had a width and height specified and when I removed the height I had forgotten to change 'size' to 'width'.
  22. Hi guys. Another image question :-/ I'm using the lazy sizes script which allows for loading of a low-res image before the lazy loaded image kicks in. It's just a case of specifying the img src as the low quality image. The code below works but generates an image 1 pixel high. I can't see where / how the 1px height is being generated as I'm not specifying any 1px high parameter // Make a very low res version $options = array( 'quality' => 5, ); echo " <img src='{$port_item->images->first()->size(414,$options)->url}' class='lazyload portfolio-thumb uk-overlay-scale' data-srcset=' {$port_item->images->first()->width(750)->url} 750w, {$port_item->images->first()->width(414)->url} 414w, {$port_item->images->first()->width(320)->url} 320w' data-sizes='407px' alt=\"{$port_item->images->first()->description}\" > Resulting HTML <img src="/site/assets/files/1211/myphoto.414x1.jpg" If I remove the $options array, I get a proportional image <img src="/site/assets/files/1211/myphoto.414x0.jpg" Even though the above seems as if the height should be 0, the image is correctly scaled Cheers
  23. Might be the best option. Thanks @Zeka
  24. Hi guys Is there a way with the image API to convert an image to B&W? I don't see it mentioned in the docs. This is my echo at the moment // Generate a very low res version $options = array( 'quality' => 1, 'upscaling' => false ); I'm basically trying some lazy loading with Lazy Sizes and this allows you to create a default low-res image until the proper image is loaded. http://afarkas.github.io/lazysizes/#examples I know I can fall back to CSS but thought I'd check when you do.
×
×
  • Create New...