Jump to content

louisstephens

Members
  • Posts

    516
  • Joined

  • Last visited

Everything posted by louisstephens

  1. Thanks Horst. I went with the switch statement, but I think I may have hit a block here. <?php foreach($page->siblings as $child) { switch($child->template) { case 'articles': echo "<li><a href='{$child->url}'>{$child->title}</a></li>"; break; default: } } ?> <?php foreach($page->siblings as $child) { switch($child->template) { case 'events': echo "<li><a href='{$child->url}'>{$child->title}</a></li>"; break; default: } } ?> I had tried using siblings to select, but I now see that it causes my biggest issue. When you are on one of the articles, it does pull in the other articles in the drop down. However, the events dropdown displays nothing. I understand that it is the "siblings" causing this. However, I really need the pages to display no matter where you are. Did I just miss a simple selector?
  2. Thanks everyone for the speedy assistance! Just curious, is it possible to inc. a if/else statement in a for each statement? Ie: $results = $pages->get("/")->children( if { "template=events" } else if { "template=articles" } else { "template=someothertemplate" } ); I just realized that I am might have many different instances of this on other templates
  3. Sorry if I have been confusing (big learning opportunity for me to get comfortable with php), this is what I have for my nav. When I used what you showed I end up with a blank dropdown list. I understand that the foreach loops through the root parent which would show just "Articles" and "Events" ( need to populate with article 1 article 2 etc etc) and have it stay on each page no matter where you are within Articles and Events. <nav class="navbar navbar-default navbar-static-top" data-offset-bottom="0" id="navbar"> <div class="container"> <!-- Brand and toggle get grouped for better mobile display --> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse container" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> <li><a href="">Home</a></li> <li class="dropdown"> <a href="" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Articles <span class="caret"></span></a> <ul class="dropdown-menu"> <?php foreach($page->siblings as $child) { echo "<li><a href='{$child->url}'>{$child->title}</a></li>"; } ?> </ul> </li> <li class="dropdown"> <a href="" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Events <span class="caret"></span></a> <ul class="dropdown-menu"> <?php foreach($page->siblings as $child) { echo "<li><a href='{$child->url}'>{$child->title}</a></li>"; } ?> </ul> </li> <li><a href="">Link</a></li> <li><a href="">Link</a></li> <li><a href="">Link</a></li> <li><a href="">Link</a></li> <li><a href="">Link</a></li> </ul> <ul class="navbar-right social"> </ul> </div><!-- /.navbar-collapse --> </div><!-- /.container-fluid --> </nav> </div>
  4. Hmm, is there a way to achieve this without selecting a parent? The template was going to be used on multiple sections like: Articles - User 1 -- Article 1 -- Article 2 -- Article 3 -- Article 4 - User 2 -- Article 1 -- Article 2 -- Article 3 -- Article 4 Events - User 1 -- Event 1 -- Event 2 -- Event 3 -- Event 4 - User 2 -- Event 1 -- Event 2 -- Event 3 -- Event 4 Sorry, I know this is a bit confusing.
  5. Well, after I thought I was near completion, a fun issue reared its ugly head. I have my tree set up like (names are just examples): Home Articles - User 1 -- Article 1 -- Article 2 -- Article 3 -- Article 4 - User 2 -- Article 1 -- Article 2 -- Article 3 -- Article 4 I have a drop down in my navigation called "User 1" (for when you are under User 1) that uses: <?php foreach($page->siblings as $child) { echo "<li><a href='{$child->url}'>{$child->title}</a></li>"; } ?> This works great as long as you Stay in user 1. However if you go to the "User 2" dropdown, everything is replaced by user 2 and user 1 no longer displays. I realize it is because I am selecting the siblings, but is there a way to go about haveing both dropdowns contained and populated no matter which article I am currently viewing?
  6. Thank you so much horst. Setting the temp pages to 0 did the trick. Have they always been set to "3" by default?
  7. Ok, so I have been scratching my head on this one for the last hour. I had three repeaters that I needed to delete from the list to create some new ones (I removed them from the template via actions). However when I go to delete the repeater, it is saying it is still use by 3 other pages. I am at a loss of what to do.
  8. I have to hop in on this and portray my thanks to LostKobraKai and everyone else on this forum! Everyone is so helpful and (and luckily for me) ignores my dumb/simple questions to help me out. As someone still learning php and processwire, it can be overwhelming trying to achieve what is in my head with the limited knowledge that I have thus far.
  9. Thanks Pete, Slowly learning more and more php as I go and definitely getting more comfortable with it. I appreciate all the help from a newbie.
  10. <?php if ($page->footerChecked->check == 1){ // 1 is checked, 0 is unchecked echo $page->footerSelect->footerPost; } else{ echo "Fail"; } ?> However, it still is posting "fail". Did I overlook something, or are checkboxes not supposed to be used this way. Sorry for any confusion: I have a template (storeFooter.php) which has 2 fields : footerChecked & footerPost. What I was trying to do was if the footerChecked was selected, display "footerPost". However, if it was not checked, display some random text.
  11. Ah ha.. more dumb mistakes by me. I didnt think I did that in 2.3, but maybe I stumbled my way through it. Thanks Ivan!
  12. Ok, I have an odd issue going on. In my templates section, I have 6 templates created and saved, but when I go to create a new page under Home, it is only showing 2 templates and wont let me select any other template. Has anyone else experienced this, and how did you fix it?
  13. I am coming up close to when I need to move over my local branch to the live site and was wondering is it actually possible to move the templates (with assigned fields) over to the new site without having to reassign the fields? I know I can backup/import the fields themselves, but I have 78 fields assigned between 2 templates that would be a pain to "redo". Thanks again for all the help everyone. I am loving processwire thus far.
  14. So I ran into a snafu the other day and all my fields etc were deleted. I do Have a backup of the fields, but was wondering how to I go about importing this rtf into processwire. Nvm, I was stupid.
  15. Thanks Adrian. I actually had gotten to that point yesterday, but noticed it was still pulling in the parents. I got it working with: return $page->parent->children();
  16. Perhaps a dumb question Adrian, I see that return $page->parent->parent(); returns the top level so: - Sup Page 1 - Sup Page 2 - Sup Page 3 - Sup Page 4 How would I drill down and list all the children of the parent? I know about first();, but didnt know if there was an "All" selector. I do appreciate all the help as I stumble through this.
  17. Ah ha.. That does the ticket. And now for something probably too confusing. I know this method would only work for this repeater on this page. However, what If I wanted to reuse this repeater and its fields on another page tree all together (without recreating the repeater everytime).
  18. Thanks everyone. Adrian, that is what I am trying to achieve, and hopefully can extract the url from that. Ill try to get some pictures up to hopefully better explain. I do apologize for seeming so vague.
  19. Thanks Adrian. The idea in my head might not be coming out in the actual post as well as I intended. The basic set up is thus: I have an Image field in my template as well as a field called 'imageURL' (all in a repeater). My hopes were that I could easily use a drop down to allow a user to change the url of the image on the fly without having to manually enter the information. The page Structure I have is: Home - Sub Page 1 - Sub 'Sub' Page - Sub 'Sub' Page - Sub 'Sub' Page - Sub 'Sub' Page - Sub 'Sub' Page - Sub Page 1 For the url field, I was hoping to just grab the list of "Sub Sub Pages", and snag the url from that to link the image with.
  20. Ah, This repeater will be used on other pages as well, so I was trying to figure out a way for the url selection to be easy on the user without having to manual input the url for every page.
  21. Thank you all for the quick responses. After rereading my original post, I think I need to clarify the issue. I have a repeater set up with: Name Image PageUrl (this is the field set to a page field). I thought by setting pageURL to a page field type, I could then select a page, and then pull that url using something similiar to what kixe describes. However, nothing is showing up in the actual dropdown. Is there a better way to allow a user to select a "url" to use for linking the image?
  22. Thanks everyone. Using MuchDev's suggestions, I got it working. Sometimes I wonder why I go about things the difficult way.
  23. I appreciate all the help thus far in learning how to navigate Processwire. However, I have hit a road block. I have an Image Field in one of my templates (it is being used in a repeater), and I would like to assign a preexisting page's url to the image . Ie: <a href="url-to-page"><img src="code-for-image" /></a> However, maybe I have missed something, as I set up the field (homepageImg) to be a "page select" but nothing is currently populating the dropdown. I am merely trying to get all the children of the parent (that the current page is in) and display them. I thought this would make it easy for someone to set the URL on the fly. Any help would be appreciated.
  24. Is it possible to create a sitemap for only one navigation element? I have several dropdowns, but really need to create a sitemap for each dropdown separately. I know this seems odd, but unfortunately the site is set up kind of weird.
  25. Thanks Diogo. I got it with: <?php foreach($page->siblings as $child) { echo "<a href='{$child->url}'>{$child->title}</a>"; } ?>
×
×
  • Create New...