Search the Community

Showing results for tags 'children'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Found 31 results

  1. Hi all, I use version 3.0.62. Is there a way to delete all children of a page with one click - without parent page? thanks
  2. SYNOPSIS A little guide to generating an sitemap.xml using (I believe) a script Ryan originally wrote with the addition of being able to optionally exclude child pages from being output in the sitemap.xml file. I was looking back on a small project today where I was using a php script to generate an xml file, I believe the original was written by Ryan. Anyway, I needed a quick fix for the script to allow me to optionally exclude children of pages from being included in the sitemap.xml output. OVERVIEW A good example of this is a site where if you visit /minutes/ a page displays a list of board meetings which includes a title, date, description and link to download the .pdf file. I have a template called minutes and a template called minutes-document. The first page, minutes, when loaded via /minutes/ simply grabs all of its child pages and outputs the name, description and actual path of an uploaded .pdf file for a visitor to download. In my back-end I have the template MINUTES and MINUTES-DOCUMENT. Thus: So, basically, their employee can login, hover over minutes, click new, then create a new (child) record and name it the date of the meeting e.g. June 3rd, 2016 : --------------------------- OPTIONALLY EXCLUDING CHILDREN - SETUP Outputting the sitemap.xml and optionally excluding children that belong to a template. The setup of the original script is as follows: 1. Save the file to the templates folder as sitemap.xml.php 2. Create a template called sitemap-xml and use the sitemap.xml.php file. 3. Create a page called sitemap.xml using the sitemap-xml template Now, with that done you will need to make only a couple of slight modifications that will allow the script to exclude children of a template from output to the sitemap.xml 1. Create a new checkbox field and name it: sitemap_exclude_children 2. Add the field to a template that you want to control whether the children are included/excluded from the sitemap. In my example I added it to my "minutes" template. 3. Next, go to a page that uses a template with the field you added above. In my case, "MINUTES" 4. Enable the checkbox to exclude children, leave it unchecked to include children. For example, in my MINUTES page I enabled the checkbox and now when /sitemap.xml is loaded the children for the MINUTES do not appear in the file. A SIMPLE CONDITIONAL TO CHECK THE "sitemap_exclude_children" VALUE This was a pretty easy modification to an existing script, adding only one line. I just figure there may be others out there using this script with the same needs. I simply inserted the if condition as the first line in the function: function renderSitemapChildren(Page $page) { if($page->sitemap_exclude_children) return ""; ... ... ... THE FULL SCRIPT WITH MODIFICATION <?php /** * ProcessWire Template to power a sitemap.xml * * 1. Copy this file to /site/templates/sitemap-xml.php * 2. Add the new template from the admin. * Under the "URLs" section, set it to NOT use trailing slashes. * 3. Create a new page at the root level, use your sitemap-xml template * and name the page "sitemap.xml". * * Note: hidden pages (and their children) are excluded from the sitemap. * If you have hidden pages that you want to be included, you can do so * by specifying the ID or path to them in an array sent to the * renderSiteMapXML() method at the bottom of this file. For instance: * * echo renderSiteMapXML(array('/hidden/page/', '/another/hidden/page/')); * * patch to prevent pages from including children in the sitemap when a field is checked / johnwarrenllc.com * 1. create a checkbox field named sitemap_exclude_children * 2. add the field to the parent template(s) you plan to use * 3. when a new page is create with this template, checking the field will prevent its children from being included in the sitemap.xml output */ function renderSitemapPage(Page $page) { return "\n<url>" . "\n\t<loc>" . $page->httpUrl . "</loc>" . "\n\t<lastmod>" . date("Y-m-d", $page->modified) . "</lastmod>" . "\n</url>"; } function renderSitemapChildren(Page $page) { if($page->sitemap_exclude_children) return ""; /* Aded to exclude CHILDREN if field is checked */ $out = ''; $newParents = new PageArray(); $children = $page->children; foreach($children as $child) { $out .= renderSitemapPage($child); if($child->numChildren) $newParents->add($child); else wire('pages')->uncache($child); } foreach($newParents as $newParent) { $out .= renderSitemapChildren($newParent); wire('pages')->uncache($newParent); } return $out; } function renderSitemapXML(array $paths = array()) { $out = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; array_unshift($paths, '/'); // prepend homepage foreach($paths as $path) { $page = wire('pages')->get($path); if(!$page->id) continue; $out .= renderSitemapPage($page); if($page->numChildren) { $out .= renderSitemapChildren($page); } } $out .= "\n</urlset>"; return $out; } header("Content-Type: text/xml"); echo renderSitemapXML(); // Example: echo renderSitemapXML(array('/hidden/page/')); In conclusion, I have used a couple different processwire sitemap generating modules. But for my needs, the above script is fast and easy to setup/modify. - Thanks
  3. How do I change the permissions for Who can access this page for a single page. This page inherits the admin template. I'm currently creating a new page called Settings using admin template and assigning it to a process of a module. I can see the Settings tab in superuser, but I can't see them in a role I defined called 'client'. So, how can i control what the client sees for admin template? Is there a page specific overwrites for permissions. I've tried allowing access in admin template view, edit. But still doesn't work
  4. Alright. So I'm converting a site I already have to Processwire (really enjoying it so far!). I wanted to convert the previous tables that I had data in to Processwire pages. But I'm wondering what the optimal way to structure pages would be. So basically, I have three main tables. Users (and all accompanying information) Items (and all accompanying information) Aquariums (each user only has 1 aquarium. Currently, user_id is a FK) Fish (type of item. Aquariums may have multiple fish) Aqua_settings (Things like lightness, temperature, etc) So in my current setup, there are a lot of Foreign Keys. I could accomplish essentially the same thing by using the Page Reference field. Alternatively, I could make fish and aqua_settings both be children of Aquarium. I could differentiate by doing $aquarium->children('template=aqua_settings'); or something. So my question is...should I be using the Page Reference field or structuring the pages as children? (Or are both equally fine depending on how I want to go about doing things)
  5. Hello, Pleased to meet you,my name is Csaba and I'm from Hungary. I've just installed processwire to more places. I created new parent and children pages. The children page links are not displayed on the right side of the parent pages. The sample About page is ok, Child page example 1 and Child page example 2 links are visible and live. But my child pages are not displayed on the parent pages. Please help!
  6. I wish to access a template's allowed templates for it's children from the API. This one: I am pretty sure this is possible, but I can't seem to find it anywhere in the documentation. If this is not possible, is there some way of assigning properties to templates? So like fields that already have a value on all pages using that template.
  7. Hey, I completely built this platform with ProcessWire (http://djmag.live/). It works fine except for the fact that some pages are still show, even when I change their state to "unpublished". They are still showing when they are returned through $object->children("template=_foo") or $pages->find("template=_foo"). Does anybody know what the problem might be?
  8. The Fotomediale is a annual festival of photography for children's and youth photography in Freiburg, Germany. This small website provides information about the festival and its workshops. Because of the topic, this site is very picture heavy. Almost every page contains it own set of images displayed in the background. The images cycle through automatically, but you can also use the buttons on the edges (or if you want arrow keys on your keyboard ). If you want to see the images, you can collapse both the navigation and content area. The transitions between pages were made with Ajax and pushState, but you can also access them directly via their URL. To handle the large image backgrounds, all of the images are lazy loaded using lazysizes. The registration form was created using the API. www.fotomediale.de Modules used: ProCache Markup Sitemap XML Email Obfuscation (EMO) Tracy Debugger Regards, Andreas
  9. I just had a duh! moment and thought I should share as it may be useful to others, especially PW beginners. I know a lot of you will go "yeah well duh...." and yeah, well I feel like a bit of an idiot but anyways.... I had a page outputting a table detailing data from about 200 records (PW pages). For each record it searched for child pages of a certain template, probably averaging 3 child pages per record and added some data from those pages to each row of the table. Simple stuff. The page was averaging about 12 seconds to load. Anyway, today I got frustrated enough to try to work out why it was so slow. Turns out I realised that the child pages I was searching for were all direct children, so I changed my search method from $pages->get(....)->find(.....) to $pages->get(.....)->children(.....) and blow me down the page load has gone from 12 seconds to a tad over 1 second. Turns out each child page had many child pages of their own (thousand of pages in total) and all these were being searched with the find() method. Stupid mistake, but I think right from the beginning of my learning of PW the find() method was ingrained. So hopefully this helps some newbies and others like me. Check out http://cheatsheet.processwire.com/page/built-in-methods-reference/page-find-selector/ and http://cheatsheet.processwire.com/page/built-in-methods-reference/page-children-selector/ for more info on these methods and others.
  10. Hello Real Beginner here. I am trying to loop the children of a product ( Keramik ) I have. They should look as an image with text underneath ( Example with bicycle tires ). I create for each product an own child page . I can't get my head around this... Thanks for all the help. Jakob I would like to have 3 Images with text on each row My structure: Each child has a Title, img and description
  11. I have a PageTable field (editions) that I need to access the top page even if the page is unpublished: $page->editions[0]->id This throws up an error when the top page is unpublished, however works fine when it's published. I know I can't access the pages as children because the PageTable order differs from the child order, and I need the top page as it is in the PageTable field. Any ideas how I may be able to do this?
  12. I am currently working on a site that lists about two hundred product series, which are displayed to the visitor as a web page. Beneath each of these Series pages are one or more children, and they may be nearly identical, with a few key differences. Does anyone have any advice on how I might run through the 'foreach' of the children on the Series' output page, and determine if the field values are the same or unique, and output the unique values while "merging" the common values? For example: Product Series A contains: Model A - which has a "color" field value of "blue" Model B - which has a "color" field value of "blue" Model C - which has a "color" field value of "green" Model D - which has a "color" field value of "red" So in this example, I'd want to list this information as: Product Series A [[bunches of info from the Series parent page's fields]] Specifications Color: Blue (Models A and B), Green (Model C), or red (Model D) Or, if the values were all the same, it would list just the value without the model mentions. Thanks in advance, even if you just have a direction to point me in, I'd appreciate any input. My brain is fried from all the crazy logic I've had to implement for this site already.
  13. I am not sure whether this has been asked before. I tried googling, but got slightly different topics, so I post this as a new topic now. Sorry. I have a «protected» page. The guest user is not allowed to view this page, only a few roles. Now the customer want this page to appear in the navigation even for guest users. When they click on the item they should be presented with the Processwire login then they should be able to view the protected page. This works if I give them the direct link, and if they are logged in, the protected page also appears in the navigation. This is the code for the navigation. It's a two-level navigation. Sorry about the alternative syntax. I know it's controversial, but I like it for templating. <? foreach (top_pages() as $top): ?> <li id="nav_<?=$top->id?>" class="top"> <a href="<?=$top->url?>"><?=$top->title?></a> <? if ($top->numChildren): ?> <ul> <? foreach ($top->children as $child): ?> <li class="sub"><a href="<?=$child->url?>"><?=$child->title?></a></li> <? endforeach ?> </ul> <? endif ?> </li> <? endforeach ?> Now, how can I get the children of $top as a given role even when not logged in?
  14. So, here I am, working at the weekend again to get this site done. I'm hoping someone can help me get over this hurdle. I'll try to explain it as best as I can. I have notes pages using a template 'note'. Children of those pages are comments, using a template 'comment'. When a comment is posted, their username is recorded in the field comment_username attached to the comment template. There is one particularly important commenter. Let's call him John. What I need to do is select new comments where at least one of the comments before that was from John. I'm trying all kinds of crazy $pages->find things, but going around in circles!
  15. I have started to use PW 3 in my latest project and it's working out really great (as expected). I have one issue though which I can't figure out. I am developing an order system, where users can log in, select a product, make some configurations to it and then order the product. The orders are saved as child pages to each user. So far, no problem. What I am trying to achieve is to put the orders in a subpage of the user called "orders", for better clarity in the users' structure. So i create a subpage "orders" with the first order of a user, and save the order as a child of this. - user - - orders - - - order1 - - - order2 - - - order3 The problem occurs when the user submits more orders: I can't get the "orders" subpage to put the new order inside it, so an additional "orders" subpage is created with each new order. - user - - orders - - - order1 - - orders - - - order2 - - orders - - - order3 This is my approach: // get the first child of the user page with the template "orders" // apparently this does not work as I expected and always returns a NullPage $parent = $user->child("template=orders"); // if "orders" subpage is a NullPage, create new page if ($parent instanceof NullPage) { $orderContainer = new Page(); $orderContainer->parent = $user; $orderContainer->template = "orders"; $orderContainer->title = "Orders"; $orderContainer->save(); $parent = $orderContainer; } $order = new Page(); $order->template = "product-configure"; $order->title = "Order: " . $order_name; $order->parent = $parent; $order->country = $country; $order->publication = $publication; $order->comments = $comments; $order->save(); Any hints are appreciated...
  16. Hi, We encountered a strange problem regarding the selector behaviour in find()/children(). Background information: Our page setup regarding the templates/fields that go wrong is as follows: Please note that both faq-category and faq-detail are hidden pages, due to the fact that we only wish to display them on faq-overview, not any where else. What's happening: We are using the following selectors to load the faq-categories and within the faq-detail pages. $page->children->find("template=faq-category, include=hidden") Then, for each child of that result, we use the following code: $questionCat->children->find("template=faq-detail, include=hidden") Results from both selector queries are 0 results. If we only use template=faq-category, 14 results (of the 18 pages, a few are unpublished, a few are hidden). If we use the code above, or any variation on it, zero results. None of these work: $page->children->find("template=faq-category, include=hidden") $page->children->find("template=faq-category, include=all") $page->children->find("template=faq-category, status=hidden|published") And now for the strangest part (because I could've just done it wrong, couldn't I): The following code dóes work and returns 16 results (the 14 published ones, 2 hidden ones, and the 2 unpublished ones aren't included, as should be): $pages->find("template=faq-category, status=hidden|published, parent=" . $page->id) $pages->find("template=faq-detail, status=hidden|published, parent=" . $questionCat->id) If anyone is able to give us any insight as of why this is happening and whether it's because we made a mistake (or it's a bug in ProcessWire? Can't imagine but... you never know), that would be great!
  17. Hello! I'm just starting off. Is it possible to have a somewhat dynamic edit area for a page? I would like the area to have fields that correspond to the children of the page. Each field is the same, but the number of them is the number of children. For example, these pages: ---Resources ------Bob ------Bill ------Joe ------Kevin Then, on the edit screen for "Resources," there would be a section for each person. If I deleted a child page, person, then the section would get deleted. Is this possible with PW? Or should I rethink my approach? Thanks!
  18. I have a events_footer.inc that outputs children pages by the id number. The id number is from a pagefield id representing the event. I would like to replace with this information from the child page: $page->event->last()->title; my events_footer.inc has this code: if($page->numChildren) { echo "<ul class='nav'>"; foreach($page->children as $child) { echo "<li><p><a href='{$child->url}'>{$child->event->last()->title}</a><br /> <span class='summary'>{$child->summary}</span></p></li>"; } echo "</ul>"; } Edit: SOLVED! I am an idiot. Code was at the bottom of my template page not my footer.inc.
  19. I am looking to display Scorecards on a rider_profile.php page. I am using a event_results.php page that has a pagetable field that generated the scorecards. The settings of the pagetable field has the pages being created under a page called scorecards. There are going to be multiple cards throughout the year for each rider depending on how many events they attend. Since there are multiple cards per rider I set the pagetable setting for Automatic Page Name Format to Ymd:His to create different folders for each scorecard. When I did that my code below doesn't work of course. How do I search the children folders? I am using $pages so I don't think I can use children() . $event_hx = $pages->get("/2014-season/scorecards/")->find("template=scorecard, Competitor~=$rider"); foreach($event_hx as $hx) echo "<li><a href='{$hx->url}'>{$hx->Event_Name}</a></li>"; Link to Dr Frankenstein's monster. EDIT: I noticed this thread suggested by the forum as related and changed the code to below and it works. $pages->get("/2014-season/scorecards/, include=all")
  20. Hey, i'm just started with Processwire, followed the tutorials and every basic thing i try seems to work, better than i expected. I already love Processwire and it's many possibilities. But now i have a very complicated (althrough for a beginner) situation. I want to get te children of a page (exist only out an image and title) and under the title and image of the children the titles and urls of the children of these children: Page Child 1 - Title - Image Child 1 of Child 1 - Title -Url Child 2 of Child 1 - Title -Url Child 3 of Child 1 - Title -Url Child 2 - Title - Image Child 1 of Child 2 - Title -Url Child 2 of Child 2 - Title -Url Child 3 of Child 2 - Title -Url Child 3 - Title - Image Child 1 of Child 3 - Title -Url I tried many diffrent ways, but it does not work at all! (i just get nothing on the page) Its getting to difficult for me as a beginner, i ended up with the following code: <?php $pagename = $page->child->title; foreach($page->children as $headimage) { $thumb = $headimage->size(600, 400); $pagename = $page->child->title; echo "<div class='section'>"; echo "<a href='$page->child->url'>"; echo "<div class='sectionimage'>"; echo "<div class='image'>"; echo "<img src='$thumb->url' alt='$headimage->description'></img>"; echo "</div>"; echo "<div class='caption'>"; echo "<p>'$page->$child->title'</p>"; echo "</div>"; echo "</div>"; echo "</a"; echo "<div class='brands'>"; echo "<ul>"; foreach($page->children->children as $childchild) { echo "<li><a href='$childchild->url'>'$childchild->title'</a></li>"; } echo "</ul>"; echo "</div>"; echo "</div>"; } ?> what am i doing wrong ? thanks.
  21. Hi all I've been using ProcessWire for a while and am completely comfortable using it. BUT, for some reason, today I am unable to echo out a page link! I have a section (About Us), which did have 4 children. Today I have added a 5th child page, but it refuses to be added to the navigation. I've echoed out the count of children and it is coming back as 4, even though there are now 5. The page is published and saves fine. I've deleted it and re-added it, to no avail. Has anyone else ever had this issue? Any suggestions more than welcome! Code for generating menu is below. $navigation = $page->rootParent->navigation; if(count($navigation) > 0) { //echo count($navigation); foreach($navigation as $p) { $children = $p->children; //echo $p->url; //echo count($children); // count children (exclude certain templates) if(count($children) && $p->is("template!=news-page|team-page|development-land-page|sheep-sales-page|produce-sales-page|grass-keep-page|property-list-page|property-auctions-page")) { // accordion header ?> <a href="#" class="submenu<?php if($page->parents->has($p) || $p === $page) echo '-current'; ?>"><?= $p->title; ?></a> <?php // expandable sub-menu ?> <div class="sub-sub-links <?php if($page->parents->has($p) || $p === $page) echo 'active'; ?>"> <?php foreach($children as $child) { ?> <a href="<?= $child->url; ?>" <?php if($child === $page) echo 'class="sub-sub-links-current"'; ?>><?= $child->title; ?></a> <?php } ?> </div> <?php } else { // single page if ($page->parents->has($p) || $p === $page) { $class = 'sub-links-current'; } else { $class = ''; } ?> <a href="<?= $p->url; ?>" class="<?= $class; ?>"><?= $p->title; ?></a> <?php } }
  22. Is there a way to have new children appear at the top of the list of children when they're first created (rather than at the bottom) whilst also allowing the user to do custom ordering? I seem to remember seeing this option somewhere but I can't find it. Perhaps I'm misremembering! Many thanks in advance!
  23. Hello, I think that an option inside templates that could limit the number of childrens that a page could have, maybe is useful in certains conditions. it´s that possible or I have to rely on hooks? thanks.
  24. For some reason this is not getting the content from the hidden child pages that I was hoping to see. $staff = $pages->get("/about-us/meet-the-team/, include=hidden")->children; ?> <div class="row firstrow lastrow"> <?php foreach($staff as $member){ echo $member->body; } As you can see, I am trying to publish hidden staff pages as content on a single page. Any clues as to what I am doing wrong?
  25. Sorry for that messy topic title but my problem seems very complicated to describe in so few words. So here a better description of my issue: I have a many product detail site under a parent called /overview/. On this product detail site is at the footer a listing of all the others product detail sites including the site itself. (all children of the parent /overview/. So i have for example: /overview/test1/ /overview/test2/ /overview/test3/ /overview/test4/ /overview/test5/ My Code look like this at the moment: <?php $overview = $pages->get("/overview/"); $overviewchildren = $overview->children("limit=4"); foreach($overviewchildren as $overviewchild) {?> <a href="<?=$overviewchild->url?>"><?=$overviewchild->title?></a> <?}?> Now on the site /overview/test1/ the code list show test1, test2, test3, test4. But i want that the child on which the user is at the moment dont show up at the list. So for the site /overview/test2/ the list should show test1, test3, test4 and test5. I hope you understand my problem , cause im from germany and to describe a php issue in english is very hard for me. Thanks a lot everybody for helping me.