Jump to content

jmn817

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by jmn817

  1. @Robin S It's always embarrassing when it's that easy, can't believe I overlooked that. Thanks for the help!
  2. Hi, I'm having some issues with one of my foreach loops that are not linking correctly. The goal is on a parent page to show the recent articles (the children) in a grid that displays the image, title, and link to the respective article. Almost everything works, I'm able to display the child's image and title fields, but the only thing that is not working is the url. It always links back to the parent page (or the page where the grid is). <?php foreach ($page->children('limit=10') as $child): ?> <div class="gridcontainer"><br><img class="gridimages" src="<?php echo $child->article_image->url; ?>" /><br> <br><div class="gridtitles"><a href="<?php $child->url; ?>" > <?php echo $child->title; ?> </a></div><br> </div> <?php endforeach; ?> My code is above, and I'm just not sure what I'm doing wrong with this approach. Thank you for your time. Jesse
  3. @Robin S Don't know how I missed this suggestion, thanks!
  4. @kongondo It appears my code is good, it's a single image field. The problem for me was in processwire, I had set the image to automatic format so it wasn't getting picked up as a single image and was just outputting a broken image (below). The directions you linked to showed what I was doing wrong. Thank you.
  5. Hello everyone, I have a relevant question on obtaining an image from another page (not a child). What I'm trying to do is obtain an image from my root directory ('/') that has a field called Center_Image. Every time I use the following code I get a small thumbnail of a broken image but not the actual image. I tested this code to get a text field and it works no problem, just the images are giving me problems. $image = $pages->get('/'); echo '<div><img src="'. $image->Center_Image->url . '"></div>'; Is there a better way to do this? Thank you.
  6. @kongondo That works perfectly, thanks!
  7. Hello everyone, I'm new to Processwire and so far things are going very well. However, I'm having trouble with one thing that would help dynamically grow the website. Below is my code that will get the pages under the root directory and list the pages from the specified folder. <ul id="trending"> <?php $root = $pages->get("/politics/2017/01/17/"); $children = $root->children("limit=5"); $children->prepend($root); foreach($children as $child) { echo "<li><a href='{$child->url}'>{$child->title}</a></li>"; } ?> </ul> Is there a way that I can have php automatically search for the newest folder under my directory, meaning the new date? I go by the date (yyyy/mm/dd) when organizing my pages, and it would be helpful if php automatically got the newest folder (day) without me having to change the folder each day in php. $root = $pages->get("/politics/2017/01/17/"); Thank you for the help, Jesse
×
×
  • Create New...