Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/20/2014 in all areas

  1. Hello everybody, I'm happy to announce that David and I have negotiated, how to continue both development and support of the AIOM module. This is our deal: Conclurer will develop and support the AIOM module from now on David will continue developing once he'll have more time available Therefore, the repository has been migrated to a new URL: https://github.com/conclurer/ProcessWire-AIOM-All-In-One-Minify At Conclurer, we are exited to take care of AIOM. For the near future, we're working on necessary bug fixes. We're also planning to release a new major version (AIOM 4) within the next months. For any new bugs in the current version of AIOM: please open a ticket on our GitHub repository. Thank you in advance, Marvin
    9 points
  2. Do you really want to have multiple image fields; or do you just want the ability to add multiple images to the same image field? The image fieldtype in ProcessWire supports multiple images - you just need to tell it so, when you go to Setup > Fields. A template can only have one occurrence of a field added to it. If you want more - you can either create multiple fields of the same type and settings but different names, or use repeaters. Have you read over the Images section of the documentation? It might help narrow down what you want to achieve.
    4 points
  3. Ok since some different things are up to the client now - but the main work was done i'd like to show my first work with PW and give some feedback and kind words about the workflow. First i've to say thank you - ryan for this awesome diamant of code and all members here that treat every other with respect and patience! Domain is not open until some bureaucratic things are ready. http://gs-altfraunhofen.de/ This was no big project but not really easy, since there was no real basic stuff to start with, and the existing things (like a strange version of the logo you could see now) are done by some teachers and changing them was a little hot political thing....hot pavement! For such a little project with less budget i give the easy http://purecss.io/ a try and work with that. Tried to give the website some individual notes, but stay with many given elements by the small CSS Framework (buttons, forms) to save time/budget for the client. Here some screenshots of the page and changing on responsive: Desktop Mobile Backend Some special modules that i used: FieldtypeEvents (with some changes) FormTemplateProcessor (with adding some spamdetection, hidden honeypot and a "leave blanc" field) MarkupSimpleNavigation PageListImageLabel ProcessAdminCustomPages VersionControl Some special adjustments and using of some modules: FormTemplateProcessor Get a Form from given fields in a backend template and save them as pages and/or send them to a mailadress....easy task with the FormTemplateProcessor. For some spamdetection a added a hidden field as a honeypot and a questfield to leave blanc to check against bots. //Changes for better Spamprotection with a hidden additional field as a honeypot // create a text input a hide it via CSS .Inputfield_name2 display:none - see CSS example on the end of this module $field = $this->modules->get("InputfieldText"); $field->label = "Name2"; $field->attr('id+name','name2'); $field->required = 0; $form->add($field); // append the field to the form //end changes /**and at the end**/ //Create a field quest in the form template with heading like "please show us youre human an leave this blanc" //Set the Spamfilter and check if field quest or spam are blank! $questfield = $this->input->post->quest; $spamfield = $this->input->post->name2; if(empty($spamfield) && empty($questfield)) { echo "<h3>Ihre Email wurde gesendet!</h3>"; // see if any errors occurred if(count($form->getErrors())) { // re-render the form, it will include the error messages $out .= $form->render(); } else { // successful form submission, so populate the new page with the new values. foreach($form as $field) { $this->contact->set($field->name, $field->value); } if($this->email) $this->sendEmail($form); //if($this->parent) $this->savePage($form); $out .= $this->successMessage; } return $out; } else { echo "<h3>Es ist ein Fehler aufgetreten - Sie haben das letzte Feld ausgefüllt bitte versuchen Sie es erneut!</h3>"; } //end changes Frontend Backend ProcessAdminCustomPages This is a real great module for custom made admin pages. You simple add a page to the admin setup the process and add a templatefile in your site folder! Admin stuff made easy even for non devs! example code from the imageoverview (CutomAdminPage Template): <?php // Bilderübersicht Custom Admin Page ?> <style type="text/css" media="screen"> /** * larget magnific popup */ .mfp-iframe-holder .mfp-content { max-width: 1200px!important; } </style> <script type="text/javascript"> $(document).ajaxComplete(function() { //add trigger class and modal setup $('.PageListActionEdit a').each(function(){ $(this).addClass("lb-edit").attr("href",$(this).attr('href')+"&modal=1"); }); $('.PageListActionNew a').each(function(){ $(this).addClass("lb-edit").attr("href",$(this).attr('href')+"&modal=1"); }); //setup lightbox $('.lb-edit').magnificPopup({ type: 'iframe', disableOn: 0 }); }); </script> <?php //get Magnific css and js $this->modules->get('JqueryMagnific'); //render PageListtree with setting the parent page $formImages = $this->modules->get('InputfieldForm'); // prep the form $wrapperImages = new InputfieldWrapper; // a wrapper $wrapperImages->attr('value', '<h2>Bilder</h2>'); $i = $this->modules->get('ProcessPageList'); // get the pagelist process $i->set('id', 1015); // setting the parent page $pageTreeImages = new InputfieldMarkup; // the placeholder $pageTreeImages->value = $i->execute(); // fill the InputfieldMarkup form field... $wrapperImages->add($pageTreeImages); // put inside the wrapper... $formImages->append($wrapperImages); // append the wrapper echo $formImages->render(); And as result i've a adminpage just with the imagetree. For this kind of websites where i've very less images and use it on different pages - i'd like to have a mediacenter - and this is the way i get it work. Using the image approach from somas imagemanger module: https://processwire.com/talk/topic/3219-images-manager-beta/ But only the setup for the templates (single image fields and cats) - and have an easy administration like the whole site in a PW style. One bad thing with a own usage of the ProcessPageList - while editing after save you will be redirected to the "real pagetree" not the custom one! So no problem, it would be much better to use a kinda a modal editing on this special content - no problem all there just to find and use. (Combined it with the PageListImageLabel to show some thumbs in the pagetree) For the images first i thought i change the Tree where in the Wysiwyg the image is choosen to insert - this works so far mor details here: https://processwire.com/talk/topic/7439-processpageeditimageselect-hook-and-change-default-page/ But then i decided to don't let the users handle images in the wysiwyg and added a fieldset TAB for images and populate them if the users choose some on the right place on every page. So i've with a Pageselect field (parent page is the image-root) a simple "click on the images to show gallery" possible on every page: Here some screens on the backend of the custom admin page for the images with the template from above: Did the same for the documents section where i again use soma setup for files as pages: https://processwire.com/talk/topic/4602-flexible-downloads-using-pages/ This is a real great tutorial - you can expand all you need for such documents for eg. a counter is simple as easy PHP: 1. Setup a single file field, a counter integer field and a template for the kind of files you are using f.e. doc.php, docx.php, pdf.php and now use such a template file <?php /** * doc.php */ if($page->doc){ $page->of(false); $page->counter += 1; $page->save(array("quiet" => true)); $page->of(true); wireSendFile($page->doc->filename, $options); } Benefits from files as pages are real SEO Links on documents and images like: http://gs-altfraunhofen.de/dokumente/morgenbetreuung.doc/ some tweaks on the contact-page and some others in the admin.php to get them always in the state i want them i've some code like this: /** * setup choosen templates to hidden - equal witch setting the user takes */ $pages->addHook('saveReady', null, 'makePageHidden'); function makePageHidden(HookEvent $event) { $page = $event->arguments(0); if($page->template != 'doc' && $page->template != 'docx' && $page->template != 'pdf' && $page->template != 'image-category' && $page->template != 'image' && $page->template != 'contact_form') return; // replace 'category-site' with your template name if(!$page->is(Page::statusHidden)) $page->addStatus(Page::statusHidden); } For me like wrote i'm not a developer, not a real good coder, but i like the way that PW (and this awesome community) teach me in the right direction and let me be free in the way to solve my challenges! So closing the circle and say again thank you to all that read this and contribute to PW and this forum! Have fun - best regards mr-fan
    4 points
  4. Databases are cute, cuddly and don't stay out late at night getting into trouble. Embrace the PW database and give it a nice home!
    4 points
  5. Hi! Those prefixes are being used only in pagination, as the title says Edit your home page, open Settings tab and change page names there.
    3 points
  6. There are two things going - the enter button I think has always done that - definitely annoying and needs to be fixed. The SEO module hasn't been approved yet, so it won't be available to install via class name. The easiest way is to use the "Add Module from URL" option and enter this: https://github.com/NicoKnoll/MarkupSEO/archive/master.zip
    3 points
  7. Hey Mike, Have you heard of the Rubber Duck? Works very well!
    3 points
  8. Hi Tom, Would it make any sense to have an option that allows you to keep the Pages sub-menu open all the time? On my installs I often have spare vertical space in the left-hand menu and having that sub-menu always open would allow single-click access to the pages tree/find/recent links. Thanks for the lovely theme regardless!
    3 points
  9. Recipes website: http://superpola.com Modules Used: ProCache ProcessImageMinimize / minimize.pw Batcher AIOM
    2 points
  10. I won't have a car for some time coming wednesday. So I already prepared and bought a universal rechargable battery at media markt. It's an external box with selectable volt output between 15 and 20 volts but with lots of A/h. So with this powering my laptop plus my internet usb dongle I will be updating my sites all back in the bus
    2 points
  11. New update: 0.3.0 Added options: - exclude Templates - Google Analytics - smart values - use parents values if empty
    2 points
  12. 2 points
  13. SEO Module? What is this? 1999 again? But seriously:
    2 points
  14. You found he best alternative to kirby for larger projects (actually, also for smaller projects), you'll just have to live with the database
    2 points
  15. If this is a requirement for you, give http://getkirby.com/ a try. It's file based, has custom fields and it's API has some things in common with PW.
    2 points
  16. You can still use your rich text editor, weaving in and out of source code mode... https://processwire.com/talk/topic/4187-formatting-a-code-block/. See posts about pbckcode plugin.
    2 points
  17. Just have a plain text field, put in your code and let the front end handle the highlighting. Two of the more popular solutions out there: http://prismjs.com/ or https://highlightjs.org/
    2 points
  18. Some reading stuff.... https://processwire.com/talk/topic/3189-one-table-per-field-rationale-and-impact/ and from ryan... https://processwire.com/talk/topic/2387-the-structure-of-fields-and-templates/?p=22762
    2 points
  19. You make some good points. When installing a module you see a screen like this: I think it would be great if the: Links More Information / Project Page / Support Page section that is present on this page was also present when viewing the details of a module once it is installed. I definitely think this is something that should be added and gives direct one click access to all the pages related to the module. Sorry for the "could not remove" errors you are getting with those two modules of mine although it sounds like a file permission problem on your server. Would you mind telling me your apache owner, the chmod values of those two files that won't delete, and their owner/group.
    2 points
  20. Oh how I miss the Blueys
    2 points
  21. Hi Martijn, Even though I hadn't spelled "method" incorrectly, your suggestion forced me to look very closely at the form. I noticed that the action value was action="/booking" It was redirecting because it didn't have a trailing slash and coming back as a GET Yay!! Cheers
    2 points
  22. This module adds a "SEO" tab to every page where you can define a special title, description, keywords, etc. Try it http://aluminum-j4f.lightningpw.com/processwire/ Name: demo Pass: demo123 How to use You can choose between include automatically or use the following methods: $config->seo // includes all the default values and configuration settings // e.g.: $config->seo->title $config->seo->keywords $page->seo // includes all the default values mixed with the page related seo data // e.g.: $page->seo->title $page->seo->keywords // for rendering: $page->seo->render . . Screenshot Download You can download it in the modules repository: http://modules.processwire.com/modules/markup-seo/
    1 point
  23. http://www.foodloversdiary.com/good-stuff/the-bowl-of-good-food-we-can-all-invest-in/ and... https://twitter.com/foodloversdiary/status/524323670630469634 In case anyone wants to retweet...
    1 point
  24. @Dazzyweb, Thanks for reminding me about this. Actually the feature had previously been requested by Adrian but I never got round to it . I was not sure how best to implement it but taking up your renderPosts() suggestion and coupled with Adrian's ideas, I have now come up with a workable solution. I will post an updated Blog version in its GitHub dev branch in the next couple of hours for testing, suggestions, etc.
    1 point
  25. Does ProcessWire have a bookmarklet that allows you to quickly save/post images, text, videos or any other content from web pages to ProcessWire pages/fields?
    1 point
  26. Is this a multiple page field? In that case you would have to iterate it with a foreach or get the first one with first() <?php foreach($page->food_types as $ft) { echo $ft->title; } ?> or <?=$page->food_types->first()->title ?>
    1 point
  27. @mr-fan, thanks for the links... that is a fascinating discussion. @LostKobrakai , thanks for the info about the same field type having different schemas... I was not aware this was an option. Seems to me that the assumption in Processwire is that all fields have the potential to be "global" (available to all pages), hence this architectural decision. I'm not sure I agree that that's the best approach, but I do see the logic behind it. Also as with everything it depends on the kinds of sites one is building. Anyway, thanks for the info guys, much appreciated!
    1 point
  28. Hey Arjen - that's brilliant! I've heard of the concept before, but never with a rubber duck. Always had someone to do it with - and they'd listen, just because they knew what my intention was. Now, I may just need a rubber duck. Or plenty of call-time to phone someone who I know is very bored.
    1 point
  29. Go for it Big and bold, strong contrasts - so it does not get lost in a landscape photo
    1 point
  30. If you want to see the tags assinged to a page in the pagelist you can use the pageLabelField for the template you need it. There you can add the pagefield you want to be shown in the list.
    1 point
  31. @Joss - Sounds good. I'll mockup a flyer and make a PDF if thats cool? Could even be tagged #processwhere
    1 point
  32. So where do you run into problems? Entering the code on the back-end? Using CKEditor or plain text? Or displaying on the front-end? If you are able to enter your code snippets in the back-end between for example: <pre><code>...</code></pre> You could use something like https://highlightjs.org/ to syntax highlight it on your blog pages in the front-end. Lots of options really, that depend also on your input scenario.
    1 point
  33. I would never recommend the use of short tags in any PHP documentation (when it's not about short tags ). It's not unlikely that someone following a doc is a newby on PHP. Letting them think about short tags obscures the main purpose of the doc, leaving less room in his mind to digest the actual purpose of the documentation. And of course all the above said.
    1 point
  34. I'm not quite sure what exactly you are after but there is this module: http://modules.processwire.com/modules/page-references-tab/ If this isn't what you are after you can probably at the least get some inspiration from it and/or modify to your needs.
    1 point
  35. There isn't a bookmarklet, and creating one would totally depend on the site where it would be used in. Would be nice, however, to create a general customisable code to be used with the "Pages web service" module http://modules.processwire.com/modules/service-pages/. Not a priority for now, but I might think of it later.
    1 point
  36. One of our TV progs (can't think which, but it may have been a kids programme or daytime magazine or similar) had this thing where they sent a teddy bear on holiday with various people. It was then photographed all over the world and the images shown on the programme. Something like that. So maybe design something like a small A4 poster that has the logo, the right colours and something on it like: "I updated ProcessWire From Here" Then you take a photo of the poster with wherever it is in the background. That could be somewhere exotic or even your back garden or down the pub. Up to you whether you are holding the poster or not.
    1 point
  37. Glad you got the permissions sorted out. I have filed a feature request on Github for adding those links to the info pages of installed modules: https://github.com/ryancramerdesign/ProcessWire/issues/746
    1 point
  38. Hi Adrian Thanks for the fast response. I will try. Nevertheless it would be great to have a link to the bugtracker of a certain module directly from the Processwire Module Page. Otherwise to much time gets simply lost in searches on how to contact somebody. There should be only one click be necessary to reach the modules page, which would be on processwire.com and from here with another click it would be great to have a link to contact the developer i.e. to make decisions or also to ask him about customizations or even to ask him to be part with this module in a project etc. It could be very beneficial for both parts. And there should be the possibility to reach immediately the bugtracker and the documentation - further documentation is linked externally. The easier it is to reach the developers and the faster you will reach the issue tracker the more issues will actually be reported and hopefully than be fixed in a timely manner which overall would improve the quality of processwire modules. Also security issues or concerns could be posted in the issue trackers. In General it perhaps would be advised to have a zentralized place for all the development and issues, i.e. redmine etc. Beside Rob and Marcus there is also an an adrian (is this you?) For the adrian the module we receive the following error: Could not remove file LICENSE by updating Downloaded zip file successfully from https://github.com/adrianbj/ProtectedMode/archive/master.zip Could not remove file ForceMatch.js after updating Downloaded zip file successfully from https://github.com/adrianbj/PageRenameOptions/archive/master.zip
    1 point
  39. You've got me thinking that I might try an upgrade from here when I'm next there: http://www.scenicworld.com.au/experience/scenic-railway/
    1 point
  40. Thanks for this. Hopefully this will shut the WP up a bit. BTW you have a typo: "A good length for a description is 160 charakters."
    1 point
  41. Gotta love it when this happens. Sit baffled for 20 minutes, open a forum thread, and solve the problem before anyone gets a chance to say anything. Ah well, as is life.
    1 point
  42. @kongondo Thanks for the module. Great work. Having a look I noticed there is no featured image option for the posts. It is quite common to add a featured photo at the top of a post and to have it on the side or top of each post listed on the blogs home page. Is that something you are looking to add or is there a way to add it to renderPosts()?
    1 point
  43. Nico: thanks, this looks interesting! Testing it right now, so might have more comments later, but first things first: you might want to add some isset-checks to module config. Seeing quite a few notices and warnings before saving module config. Sorry, forget that, it's not about config. The problem is occurring in init(), when trying to check for $this->page->template. While viewing the module settings, $this->page doesn't seem to be available yet, which is causing some issues Edit: here's a diff for changes I had to make locally to get this module running. Wouldn't work at all before that, possibly because I've got debug mode on. Not sure if they're all required, implemented the way you'd want them, etc. and some of them might be specific to my environment. Also, moving the hooks from init() to ready() should ensure that API is ready by that time, but it could cause other (potentially unwanted) side-effects.. diff --git a/MarkupSEO.module b/MarkupSEO.module index fecc6a3..c2ebb86 100644 --- a/MarkupSEO.module +++ b/MarkupSEO.module @@ -57,7 +57,7 @@ class MarkupSEO extends WireData implements Module, ConfigurableModule { * Initializing the hooks * */ - public function init() { + public function ready() { $this->addHookAfter("ProcessPageEdit::buildFormContent", $this, 'addSEOTab'); $this->addHookBefore("ProcessPageEdit::execute", $this, 'saveSEOTab'); @@ -85,9 +85,10 @@ class MarkupSEO extends WireData implements Module, ConfigurableModule { $page = wire('pages')->get($this->config->input->get->id); $pageData = $this->getPageSEO($page->id); $configData = wire('modules')->getModuleConfigData($this); - $mixedData = array_merge((array)array_filter($configData), (array)array_filter($pageDataDefault)); + $mixedData = array_merge((array)array_filter($configData), (array)array_filter($pageData)); + $this->modules->get('FieldtypeFieldsetTabOpen'); $field = new InputfieldFieldsetTabOpen; $field->name = $this->prefix."meta"; $field->label = $this->_('SEO'); @@ -158,6 +159,7 @@ class MarkupSEO extends WireData implements Module, ConfigurableModule { $e->return->add($field); + $this->modules->get('FieldtypeFieldsetClose'); $field = new InputfieldFieldsetClose; $field->name = $this->prefix."meta_END"; @@ -204,7 +206,19 @@ class MarkupSEO extends WireData implements Module, ConfigurableModule { */ private function getPageSEO($id) { $dataOrg = wire('modules')->getModuleConfigData($this); - return $dataOrg['pages'][$id]; + if (isset($dataOrg['pages']) && isset($dataOrg['pages'][$id])) { + return $dataOrg['pages'][$id]; + } else { + return array( + 'title' => '', + 'keywords' => '', + 'description' => '', + 'image' => '', + 'canonical' => '', + 'robots' => '', + 'custom' => '', + ); + } } /**
    1 point
  44. http://tjmahaffey.com/blog/cron-legacy-scheduling-a-mysql-query/ "cron-legacy-scheduling-a-mysql-query" is not a url segment - it is a child of the blog page. All you need for that is to echo $page->name Nico mentioned this above already. URL segments are extra paths added to the url as a way of passing values to the page. Instead of: http://tjmahaffey.com/blog/cron-legacy-scheduling-a-mysql-query/?boolean=true&this=that echo $input->get->boolean; // true echo $input->get->this; // that You can do: http://tjmahaffey.com/blog/cron-legacy-scheduling-a-mysql-query/true/that/ echo $input->urlSegment(1); //true echo $input->urlSegment(2); //that
    1 point
  45. Thanks Nico!! Sure, here you go
    1 point
  46. Thanks OrganizedFellow, Learning new things is core to human nature. When you stop learning, you'll become depressive. ps, That OrganizedFellow is really organised. (I saw his bookmarks:-)) We know he invested in learning, he succeeded. It's a pleasure to have him here.
    1 point
  47. Joss actually emailed me a similar question and I'll duplicate my reply here since it seems relevant: Performance as it relates to database is really not an issue that one needs to consider much (or at all) when it comes to creating their fields. Most field data in ProcessWire is loaded on-demand. It loads data selectively and only when it needs it. This enables it to be highly memory efficient with large quantities of pages in memory at once. When you have a $page, behind the scenes, none of the page data is actually loaded until you access it. For instance, if you access $page->body, then it goes and retrieves it at that moment (if it hasn't already retrieved it before). MySQL is extremely fast with simple primary key, non-joined selects, and we take advantage of that. What I'm trying to get across is that quantity of fields does not translate to an increase in joins or other factors that would slow the system down. Where ProcessWire does join data automatically is at page load time is when you check the "autojoin" box on a Field's "advanced" tab. Some fields you know will always be needed with every $page instance, and that's what autojoin is for. Typically, I make my "title" field autojoin, as it is already by default. I've hidden that autojoin option under the Advanced tab simply because most people never need to consider it. The original intentions behind autojoin have become less applicable than I originally thought [with regards to performance], so it's not something that comes up that often. ProcessWire also uses joins when it performs queries for $pages->find("selector"), and related DB-querying selector functions. It joins all the tables for fields that you query. So if you perform a find for "date>2012-12-19, body*=holidays" then it's going to join the field_date and field_body tables when a value matches. Though it doesn't do this for the purpose of loading the data, only for matching the data. Technically this type of query could be potentially faster if all those fields were in one table. But that doesn't translate to results that matter for us, and doesn't affect the way that you should use ProcessWire. The benefits of our one-table-per-field architecture far outweigh any drawbacks. I put a lot of time into finding the right architecture and balance here when coding ProcessWire 2. Incidentally, ProcessWire 1 did use the one-table approach (all the field data was stored with the page rather than in separate tables) and it was far less efficient with memory, and about the same in terms of performance. It's better to re-use something like "body" (when possible) rather than create "article_maintext" or other template-coupled variations like that. The reasons for that are for your own benefit. It is less to keep track of, and tends to foster better consistency. It also results in more reusable code and broadens the potential of where the data can be used. Take the example of an on-site search engine, like you see in the upper right corner of processwire.com. If we know that the main text field(s) of most templates has some consistency in their field names (like title and body), then we can write code that doesn't need to know whether something is an article, a press release or a product. We can find all pages that match "holidays" in the text just by doing this: $pages->find("title|body*=holidays"); But if created a separate textarea field for every template, then any code that queries those fields needs to know a lot more about them: $pages->find("title|article_maintext|pr_maintext|product_maintext*=holidays"); While that still works, it doesn't scale nearly as well. This also translates to the code you use to output the results. If you want to show a snippet of the matching text with the search results, you are going to have a lot more fields to consider than just "body". Now if each of your templates genuinely needs very different settings for each of their main text fields, then of course it's fine to create them as you need them. But in the real world, I think you draw more benefit by planning for reusability when possible. The benefits are for you (the developer), as it doesn't matter much to ProcessWire. Reuse fields where it's obvious that the name of the field makes sense in the context of multiple templates. If template "employee" needs a date_of_birth field and template "press_release" needs a date_publish field then just create one field called date and use it on both templates. On the other hand, if you need multiple date fields on the same template (like date_unpublish) then more specific field names start to make sense. In that case, I would usually use my date field for publish date, and create a separate date_unpublish field for my unpublished date field. Though some may prefer to actually have separate date_publish and date_unpublish fields because they are obviously related by name. Ultimately, use what works best for you, but always keep an eye out for obvious reusability potential with fields. I think that most people naturally arrive at the right balance for their needs after some experimentation. What is a best practice for one need might not necessarily be for another. So these are mostly general purpose guidelines and people should find what makes the most sense in their context. For the majority of cases, I think avoiding tightly coupled template and field names is a better strategy. TL;DR: It doesn't matter to ProcessWire what you do. Aim to reuse fields when you can and when it makes sense, for your benefit.
    1 point
  48. If you wanted all grandchildren, and nothing deeper, you could do this: $page->find("parent=$page->children"); If you wanted grandchildren and anything deeper, you could do this: $page->find("parent!=$page"); If you wanted children, grandchildren and anything deeper, you could do this: $page->find('');
    1 point
  49. You mean why "$page->children()->children()" didn't work? ("$page->parent->parent" actually works to get the grandparent of a page.) Well it's simply that "children()" returns a 1 dimensional page array, so it works only with 1 explicit parent. As it would have to do a multidimensional page array which doesn't exists as far as I know. So a simple loop is needed here like diogo provided. Though I would do it with some check and a little simpler. Also there's a typo in the example of diogo. $channels = $pages->get(5766)->children(); foreach($channels as $channel) { if($channel->numChildren){ // has any children? echo "<h3>" . $channel->title . "</h3>"; foreach($channel->children() as $videopage) { echo "<p>" . $videopage->title . "</p>"; echo "<p>" . $videopage->videourl . "</p>"; // or whatever you need } } } Remember you could also add selectors to children("string"). Or if you want just to get all videos, you can use the ones diogo showed, but I'm not sure it will work or return a page array with only using "$pages->get("template=video")". I think something is missing, usually "get()" returns a single page. Following is the best method to use. You could limit it to the "Video" branch, so it doesn't need to scan whole site. $videos = $pages->get("/videos/")->find("template=video"); foreach($videos as $vid){ ... Or what I think diogo wanted to write is something like this. $videos = $pages->find("template=video"); But this will search through whole site structure. Something you might want to limit.
    1 point
×
×
  • Create New...