Jump to content

Search the Community

Showing results for tags 'page'.

  • 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

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

  1. I'm trying to create tests using PHPUnit, and I have the following method: protected function _getRootItems(Page $currentPage) { /** @var Page $page */ foreach (wire('pages')->find("has_parent!=2,id!=2|7,status<" . Page::statusTrash . ",include=all") as $page) { if ($this->_isActivePage($page) && $page->parent_id == 1) { $output[$page->sort] = [ 'id' => $page->id, 'title' => $page->title, 'url' => $page->url, 'template' => $page->template->name, 'isActive' => $page->id == $currentPage->rootParent->id, 'children' => [] ]; } } ksort($output); return $output; } I want to write a test for this method in PHPUnit. I end up with the error: Trying to get property of non-object This is because $currentPage->rootParent is null. My test looks like this: public function testGetRootItems() { $mock = $this ->__getMock() ->disableOriginalConstructor() ->setMethods([ '_isActive' ]) ->getMock(); $mock ->expects($this->any()) ->method('_isActive') ->willReturn(false); $page = $this ->getMockBuilder(\ProcessWire\Page::class) ->disableOriginalConstructor() ->setMethods([ '__get' ]) ->getMock(); $rootParent = $this ->getMockBuilder(\ProcessWire\Page::class) ->disableOriginalConstructor() ->setMethods([ '__get' ]) ->getMock(); $template = $this ->getMockBuilder(\ProcessWire\Template::class) ->disableOriginalConstructor() ->setMethods([ '__get' ]) ->getMock(); $template->name = 'name of the template'; $rootParent->id = 1; $page->template = $template; $page->id = 2; $page->rootParent = 'hierzo!'; var_dump( $page->rootParent ); $method = $this->__getReflectionMethod('_getRootItems', $mock); $method->invoke( $mock, $page ); } I've already tried to override the rootParent with it's method (___rootParent), tried setting it directly ($page->rootParent) but so far nothing worked. I probably miss something really simple here. I know that in my example, I set the value to a string. But the result of the var_dump below it is still NULL. I also tried setting it using $page->rootParent = $rootParent, this had no effect. So my question: How can I possible override this rootParent variable?
  2. Hi, I just wanted to check whether or not the following topic is still valid with respect to PW 3.x: https://processwire.com/talk/topic/22-how-to-build-a-news-page/ I am trying to integrate a news section into a basic multisite PW website installation (voluntary project) intended for a community of two villages. Currently there are 4 subdomains (hca-site, hfi-site, hhg-site, hps-site) that link back to the main domain website (https://thehanneys.uk) by clicking on their home buttons. I had a look at the Blog (ProcessBlog & MarkupBlog) module but it is not really what I'm looking for - a simple News section. At the moment we're just concentrating on getting the functionality in place. The styling can come later. The first issue encountered is that there is no checkbox under the Advanced section for "Page Numbers" to turn them on for the news-index template. Secondly, I don't understand why the following text is being displayed above the navigation when I expected it to be displayed after the page title. Thirdly, are the story pages displayed on the index page simply by creating a new child under News (page based on news-index.php template)? Showing 0 of 0 Article(s) | Page 1 of 0 The current code for the news-index.php template is as follows: <?php namespace ProcessWire; // basic-page.php template file // See README.txt for more information // Primary content is the page's body copy $content = $page->body; // If the page has children, then render navigation to them under the body. // See the _func.php for the renderNav example function. if($page->hasChildren) { $content .= renderNav($page->children); } // if the rootParent (section) page has more than 1 child, then render // section navigation in the sidebar if($page->rootParent->hasChildren > 1) { $sidebar = renderNavTree($page->rootParent, 3) . $page->sidebar; } // start the news stories list echo "<ul>"; // get the stories for this page $stories = $page->children("limit=6, sort=-date"); // note if you set the stories to sort by date descending on the /news/ page // in the admin, then you can omit the "sort=-date" above. // cycle through each story and print it in a <li> foreach($stories as $story) { echo " <li><a href='{$story->url}'>{$story->title}</a> <p><strong>Date:</strong> {$story->date}</p> {$story->body} </li> "; } echo "</ul>"; // get values for our placemarker headline $start = $stories->getStart(); $end = $start + count($stories); $total = $stories->getTotal(); $num = $input->pageNum; $lastNum = ceil($total / $stories->getLimit()); // output the placemarker headline echo "<h5>Showing $start - $end of $total Article(s) | Page $num of $lastNum</h5>"; // output pagination links echo $stories->renderPager(); The current code for the news-story.php template is as follows: <?php namespace ProcessWire; // basic-page.php template file // See README.txt for more information // Primary content is the page's body copy echo "<div id='bodycopy'>"; $content = $page->body; echo "</div>"; // If the page has children, then render navigation to them under the body. // See the _func.php for the renderNav example function. if($page->hasChildren) { $content .= renderNav($page->children); } // if the rootParent (section) page has more than 1 child, then render // section navigation in the sidebar if($page->rootParent->hasChildren > 1) { $sidebar = renderNavTree($page->rootParent, 3) . $page->sidebar; } P.S. Are there any books/tutorials specifically covering PW 3.x? Any assistance would be greatly appreciated.
  3. I've been experimenting with field type Page, to add a page within a page (to replicate a block like system). I encountered some issues rendering the results, and while debugging and displaying the $page->fieldtypePage object I realised it was huge. I mean 1 minute to display huge. Even though in normal operation, printing out the whole object wouldn't be necessary. However I presume having an object that large must affect site performance. I won't be using this field type Page any more because I'm a bit of a fanatic for clean code and good performance. But in general, what do you think? Should this be submitted as a bug? If so, what's the correct procedure for that?
  4. I'm confused by how Processwire should display custom fields. I have Home page set up with a field type Page (called 'blocks'), and that field has one page selected (called 'footer'), and that page contains 3 fields. The idea is that this footer page is reusable as a block on any other page, while also being fully editable in the backend (and only needing to be edited once to change on all pages). This is as close to a Drupal blocks approach as I could get. In principal, certainly from the backend, this is working fine. It's clear enough for a site editor. The issue is how to display this 'blocks' field (the page attached to it and content of fields that page contains). This system only works if I can display that field, without needing to specify or hard code the page name within the field, or fields within that page (because this may change later). The one constant will be that the 'blocks' field is always linked to selected page templates. Based on what I understand of Processwire logic, because I display the title with $page->title, I would have expected the following to work: $page->blocks or $page->fields->get('blocks') This however only returns what I presume is the field ID. I have looked through the docs, but they are light on highlighting typical uses (perhaps an example for each api element that shows how it works and why it exists in relation to backend data to frontend display, similar to the PHP manual. Something perhaps I can help with at a later date). I also think this is a type of issue can be a deal-breaker for new users because of the logic gap ($page->title outputs field content, $page->blocks outputs what might be field ID), and us newcomers can be an impatient group! So I hope solutions here will be a useful addition to the docs. After I learn how to deal with this, I'll add any info that might be useful for newcomers.
  5. I'm interested to know a good approach to grouping pages, where one page may be in two different groups (but re-using the same page for easy client editing). To clarify for those familiar with Drupal, there I would probably use Taxonomies, Blocks and Context modules. A taxonomy term for each group would be attached to pages (nodes), much like product categories would be, and menus and links would use Taxonomies (the Context and Blocks for displaying different elements on page depending on which group was accessed, but I don't need this part now) . Example organisation as follows (this is not PW Tree): Home - Courses - - Course One - - Course Two - - Course Three - - Course Four - Adult Courses - - Course One - - Course Two - Junior Courses - - Course Two - - Course Three - - Course Four - Summer Courses - - Courses Three - Special Courses - - Course Four (The PW Tree would need to be with only one occurrence of each Course page) I'm keen on the cleanest solution, ideally not adding modules, and a PHP solution no problem (though if it can be within PW as-is, great)
  6. Hello! I searched a lot to find various solutions to the problem of setting a custom publish date. Which is a must if you do a redesign of a website and need to write import scripts. Since I can't re-use the database. I understand that there is no field to set the dates for created/modified/published manually, but this should be at least possible with the page API. So I tried to set the published date via API: $page->of(false); $page->published = 1486297829; $page->save(); Which did not work, whenever I ask for $page->published, I get the date back that was first set when publishing the page. So I researched a little more and found that the Page class stores the published date in $page->settings['settings']; (see Github) I also tried $page->set('published', 1486297829); but with no success. Is it possible that this has to be done via SQL? Why? Why can't I use the API? Or do I miss anything? Thank you a lot in advance!
  7. I enabled language support and now I get "Trying to get property of non-object" for lines like: <p><?= $page->text ?></p> The content is still available in the backend. On another page I get text from the frontpage with: <?php $somepage = $pages->get(1); ?> ... <p><?= $somepage->text ?></p> This outputs the text although on the frontpage it doesn't. I also do this on the header. On the frontpage I added some fields that are thus "shared" among all pages the content fails with the error for `<?= $page->text ?>` but not for `<?= $pages->get(1)->text ?>`. On a third page everything works as expected All three pages have different templates. Additionally if the field is wrapped with frontend editing like so: <p><edit text><?= $page->text ?></edit></p> The page source will end up like this: <p></edit></p> Before having to dig deep into this: Any idea what it could be? I var_dumped $page and that gives an object.
  8. Last night I run into issue. I was trying to empty my trash that have 140 000+ pages init. All pages have repeater fields. When I pressed "Empty" on trash menu I wasn't able to use back-end for 2h+ (I kept refreshing page when It time-outed). After PW process was done 30k pages were deleted. I'm still left with 110k pages to remove. Is there a way to safely remove all pages but with increased speed? Thanks
  9. I cannot manage to delete this page upon uninstallation of a Process module I have that was working previously. I thought the only difference would be that I added `namespace ProcessWire;` to the start of the module PHP, however I've tried without it and still I get It is an admin page. Right now I have $get = 'template=admin, parent!=trash, name=importall, include=all'; $gp = wire('pages')->get($get); if($gp->id) { wire('log')->save($log, "$gp->id".get_class($gp).__NAMESPACE__); $gp->delete(); if(!wire('pages')->get($get)->id) wire('log')->save($log, "Deleted Imports page."); } previously $gp = $this->pages->get('template=admin, parent!=trash, name=importall'); if($gp->id) { $this->pages->delete($gp, true); $this->log->save($log, "Uninstalled ". get_class()); } Why will it no longer delete? I can't even do so by the GUI.
  10. For some reason when I unpublish an already-published page, even of a template other than the specified 'importer', all its fields are cleared on page render. How do I understand and remedy this? Peace & thanks public function init() { $this->addHookAfter('Page::render', $this, 'renderEditor'); } protected function renderEditor(HookEvent $event) { $here = $event->object; $page = $this->pages->get($this->input->get->id); //$this->log->message($page->template.$here->process); return; if ($here->process != 'ProcessPageEdit' && $page->template != 'importer') return; $css = $this->config->urls->ProcessImportAll . 'ass/ProcessPageEdit_importer.css'; $event->return = str_replace("</head>", "<link rel='stylesheet' type='text/css' href='{$css}'/>\n</head>", $event->return); $field = wire('fields')->get('name=pi_template'); if (count($field->templateTypes)>0) { $templates = $field->templateTypes; } else { $templates = []; foreach (wire('templates') as $tpl) $templates[] = $tpl->id; } sort($templates); //$tplTypes = json_encode($templates); $templatesFields = $this->getTemplatesFields($templates); $templatesFields = json_encode($templatesFields); $js = <<<EOT <script> $(document).ready(function(){ if (!document.getElementById('Inputfield_status_2048').checked) { $('#ProcessPageEditContent *').prop('disabled',true); } else { var all = $templatesFields; var sel = '#Inputfield_pi_template option[selected="selected"]'; var tpl = getTpl(); var arr = all[tpl]; var def = '<option value=""></option>'; $('#Inputfield_pi_match').prepend(def); filterFields(tpl); $('#wrap_Inputfield_pi_template .asmListItem .asmListItemRemove').click(clearFieldOptions); $('#Inputfield_pi_template').change(function() { var on = $(this).find('option[selected="selected"]')[0]; if (on !== undefined) { tpl = on.value; //console.log('clicked ' + tpl); filterFields(tpl); } else { tpl = null; clearFieldOptions(); } }); function filterFields(t) { if (t != null) { $('#Inputfield_pi_match').prop('disabled',false); arr = all[t]; //console.log(arr); $('#Inputfield_pi_match option').each(templateFieldOptions); $('#wrap_Inputfield_pi_fieldmap select option').each(templateFieldOptions); $('#_Inputfield_pi_maptab').click(function() { //$('#wrap_Inputfield_iu_fieldmap select option').each(templateFieldOptions); }); } else { clearFieldOptions(); } } function getTpl() { if ($(sel).length>0 && $(sel)[0].value) { var tpl = $(sel)[0].value; } else { var tpl = null; } return tpl; } function templateFieldOptions() { var val = parseInt(this.value); if (!arr.includes(val) && val>0) { //console.log(val + ' ' + arr); $(this).prop('selected',false); $(this).prop('disabled',true); } else { if (arr.includes(val) && val>0) { //console.log(tpl); $(this).prop('disabled',false); } } } function clearFieldOptions() { $('#Inputfield_pi_match').find('option[value=""]').first().prop('selected',true); $('#Inputfield_pi_match').find('option[value!=""]').each(function() { $(this).prop('disabled',true); }); $('#Inputfield_pi_match').prop('disabled',true); $('#wrap_Inputfield_pi_fieldmap select').find('option[value=""]').first().prop('selected',true); $('#wrap_Inputfield_pi_fieldmap select').find('option[value!=""]').each(function() { $(this).prop('disabled',true); }); $('#wrap_Inputfield_pi_fieldmap select').prop('disabled',true); } } }); </script> EOT; $event->return = str_replace("</body>", "$js</body>", $event->return); //$this->filterFieldFields($event); }
  11. I created custom admin page with link in top menu and set template for it. But opening it has another admin theme, not like is used in core admin pages. So here is two screen shots. Does anybody know how to solve it. And one more thing)) I included just small peace of code in this custom template for my admin page: <?php namespace ProcessWire; require($config->paths->adminTemplates . 'controller.php'); Thanks for advice!
  12. Hi all, I'm still new to processwire and now I have to create the first hook. I need to modify the page-clone module, so there is a field in pages that has to be empty after cloning the page. How could I start this task?
  13. Hello, On my website I want to import categories from another website based on prestashop. For each categorie a new child page will be created, but if I want to import the categories again because there were some changes made in the categories in Prestashop, then the page has to be updated and not create a new page. So I tried the following: $parent = $this->session->Parent; foreach($categories as $item) { //make sure end of string ends with alphanumeric $str_catlink = $item['link_rewrite']; $category_name = preg_replace('/[^a-z0-9]+\Z/i', '', $str_catlink); // see if we already have this item $page = $parent->child("name=($category_name)"); // if we don't have this item already then create it if(!$page->id) { $page = new Page(); //etc etc etc But if I want to import the same categories now, there is an error: Call to a member function child() on a non-object. How can this be solved? Does anyone have an idea?
  14. Hi Guys, something I'm wondering about: is there any easy solution to show the template (or template label) within the page tree in the backend. The reason I'm asking is because we have a page tree consisting of many different pages and templates on the same level. For editors it would be nice to be able to see what template each page has without having to navigate into the page... Cheers, Kurbel
  15. Hello Fellow PW fans. I have since i started using PW allways been a bit afraid to use the API:s more advanced functions. Like creating pages or subpages on the fly in my PHP code in the page template file. So i read alot and finaly got a Eureka the other day. And have now tinkered around a bit and this simple example is the result. It´s just the bare basics. You could make this more advanced in infinity. I wanted to put this example somewhere for the future because i don´t think there is such a clean to the point example anywhere on the forums. All the others are deep within discussion threads with advanced stuff that are not of concern for people who looking for a simple example to start from. Notes: You should log in as admin before trying to run this code in your page template. I put the parent page i use in my testing as unpuplished for security. As allways, the API reference: https://processwire.com/api/ref/ is allways great to have when tinkering with the API. Any ways, here it comes, and you have to change paths and such to your requirements. <?PHP /* some random strings and stuff for testing */ $randTitle = 'test_' . mt_rand(0, 1000000); $randHash = 'test_' . md5(mt_rand(0, 100000) + time()); /* Example: Creating a new sub page to a parent page via API Author: EyeDentify This example do not check if the page name allready exist it just tries to save it no mather what. so you have to create that check your self. */ /* get parent page object to add sub page object to */ $addParent = $pages->get('/api-test-start/'); /* Instantiate a new page object */ $newPage = new Page(); /* turn output formating of for property manipulation */ $newPage->of(false); /* set the page objects parent so it is saved in the right place */ $newPage->parent = $addParent; /* set the name of the template to be used wich we uploaded before hand. */ $newPage->template = 'tmp_api_test_post'; /* sanitize and set page name and also used in the path */ $newPage->setName($sanitizer->pageNameUTF8($randTitle)); /* the title */ $newPage->title = $sanitizer->text($randTitle); /* set custom fields propertys, the ones we created ourselfs */ $newPage->api_test_hash = $randHash; /* save the page object to database as child of the given parent */ $newPage->save(); /* turn on output formatting again, importent because it should be ON when outputting it in template files later on. */ $newPage->of(true); ?> This is kind of a example and code template in one. I hope this can get others started that are beginners like myself to get more advanced with the PW API. I expect there is propably things that should be done a certain way but this is my way. Good luck with your API adventures. Update created a gist for the github users of the PW community of this example. https://gist.github.com/magnusbonnevier/4dbb3a28634a9b76bbf5855dd871606f
  16. I have a page that are either ) showing an automatic list of all pages with a certain template, if no pages are selected in a page field. 2) Or showing the selected pages from the page field. if ($page->custom_menu->count == '0') { $subjects = $pages->find("template=subject-page, sort=title"); } else { $subjects = $page->custom_menu; } When I set these "subject-page"-pages to hidden. The first option excludes these from the list as they should. But the second manually selected list will still show hidden pages. I have checked that these are actually hidden, with the following code: if ($subject->status & Page::statusHidden) { echo "I'm hidden!"; } else { echo "And I'm visible!"; } If I am not wrong, hidden pages have been removed from page fields by themself before, because of their status. But I'm not sure. I haven't used include=hidden. I am on ProcessWire 3.0.32, the page field is using PageListSelectMultiple*+.
  17. Hey, I was wondering if there's a way to add more fields to specify when creating a new page. At the moment, the only two fields are required for creating a new page. Title Name (Automated) I've configured processwire so that the chosen page to create is limited to one template. Guess this would make the process to achieve the above a bit easier. Regards,
  18. Hi, I have one xml FEED and I want to create pages for each item in XML via API. First time i am trying to create page with API, every thing is working fine but the issue is 1. its creating duplicate pages every time i run that XML. i have one unique field in XML called item_id & i want to create page with item_id as page name, i want to check that if page exist with item_id name before creating page. how can i do that ? Thanks
  19. Hello, I am developing an Inputfield Module for a Page Field that has the user interact with a modified InputfieldSelector. I have added buttons on InputfieldSelector to modify a hidden HTML textfield that I have appended to the module rendering. I would like to save the textfield's contents to the database. My question is, how would I do that, given that the module is of type Page? Let me know if clarification is needed. Thanks.
  20. Hi Still on my quest to build my website. Since now I know how to basically display fields, I'm now at a design' step. I know I can do, what, and how, I want using PW, but there is so many possibilities! Could you help to choose the more efficient technique and/or point me pro and cons of each of them? My page is a classic team page Team Some text Director 1 (photo+text) Director 2 (photo+text) Other members ~35 photos separated in differents categories (photo, name and position title) Some text Method 1 : a page for each section. Pictures uploaded in one field, as described here. Using photo tags to create the different sections and description for name and position. Method 2: each person is a page. A field "category" will be added to displayed them correctly. Method 3 : repeater but I'm not sure yet how it works and his advantage or inconvenient. I have 35 photos to upload for now (one time upload, after I will add/modify only 2-3 by year). I was thinking using a module to batch Import via CSV to create pages (which seems to speed up with method 2) (However, I don't know if it's working for images). On the other hand, method 1 is also easy for uploading pictures in 1 click. However, adding description in batch seems more complicated and less easy to maintain (more clicks to see them). Also, subsidary question. If I want to re-use some pictures in an other webpage, is it easier to reuse from this page or just reupload and recreate a child page in an other page? Do I miss something? Thanks Melanie
  21. Hi Guys I have a question about the Add Page Shortcut Functionality. In General you can set the family settings on template so that you have to choose a new Parent when adding a new page of the defined template with the shortcut menu. In my case I can add new "Newsletter" Pages but I have to choose under which Parent it should be added. But as a "Clinic" - User I can only add the Newsletter Pages under the Parent Page which belongs to this User (was made with a Hook inside Page::addable / Page:editable). Because of that I only see one Parent Item in the Dropdown Shortcut Menu which is correct. Can this Selection be skipped when the shortcut menu only has one Parent to choose (Also in ProLister "Add New")?
  22. How do I get the output of a field that is a FieldTypePage? I've tried echo $page->first_name . " "; but it just prints numbers instead of picking data from that page it's referencing to. Couldn't find any info on how to use this module/field either.
  23. Hi all, I am using Processwire to synchronize Albums form a Facebook Page into Processwire. Works like a charm! I'm using two loops to synchronize the albums One loop that creates a page that stands for the "album" One loop that stores every image within the album as a child of the "album" I experienced that this loop however only synchronizes the first 25 images. I was wondering, is there any kind of limitation that comes with the page creation API? I used the following script as posted before by Ryan if I'm not mistaking $p = new Page(); $p->template = "fb_image"; $p->parent = $pages->get("name=$id"); $p->title = $hash; $p->name = $hash; $p->save(); $p->fb_image = $image["images"][0]["source"]; $p->save(); Hope someone has the answer!
  24. It would be very nice to be able to save page with common shortcut (e.g. CTRL + S on windows) in admin. Live long PW
  25. I'm just wondering if there a way of creating block like functionality similar to say Episerver / drupal blocks?? I guess i could treat the template as a view that loads in sever partials (kinda like blocks) ?? Any ideas on this would be great.
×
×
  • Create New...