Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/05/2016 in all areas

  1. $journeyArray = $journey->getArray(); $idArray = explode("|", $session->journey); usort($journeyArray, function($a, $b) use ($idArray) { $keyA = array_search($a->id, $idArray); $keyB = array_search($b->id, $idArray); return $keyA < $keyB ? -1 : 1; }); $journey->setArray($journeyArray);
    3 points
  2. I just noticed, that this might actually be a great option for packing offline, html+js only apps for clients (e.g. localstorage needs an server to function). Just let them double-click the thing and it's working.
    2 points
  3. I don't get why you want to use wireRenderFile when you have a template to work in. What I often do in a template is: $body = ''; if (count($page->pagetable_content)) { foreach ($page->pagetable_content as $row) { $row->set('source', $page); $body .= $row->render(); } } And then on the rendered page ($row) // No direct access to this page, loaded via page table. if (!($page->source instanceof Page)) { throw new Wire404Exception(); } This way my rendered page is protected for direct viewing and I have access to the 'original' page via $page->source.
    2 points
  4. This is updated/version of the AdminDocsTab module as was posted here: https://processwire.com/talk/topic/11803-admindocstab/ (that one is now obsolete) https://github.com/outflux3/AdminHelp AdminHelp module for ProcessWire Processwire helper modules for managing site documentation. Currently alpha state - please use with caution and report all errors. Instructions There are 3 modules included with this: the master module holds the settings for the other 2. This is a helper module which expects you to have already setup a hidden part of your page tree* to establish your help documentation, using any template (e.g. 'help-doc') and a body field (ckeditor) (*or you can run the setup and it will create these items). The help-doc template does not need to have an output template, as the module will only echo the body field inside the admin. In addition this 'help-doc' template requires "template select" field (separate module) which should be named template_select. (if you run setup it will create this). To have a global help page, which renders all of the help docs in an accordion view, you can install the ProcessAdminHelp module, which will setup a page to view the help docs, under setup. Help Setup Module (AdminHelp) This is how the setup module looks before setup is completed: If you use the automated setup, it will create the field, templates and pages, and will auto-set the module configuration: Example Help Tab (when using AdminHelpTab) Admin Help page (ProcessAdminHelp) This shows all help docs in accordion. (it is capable of displaying child pages also but this is not currently implemented in the module due to the family settings of the default templates). Accordion opened: Features Summary: Manages settings for the help templates (help-index, and help-doc), which enabled users to add new help docs where applicable; these can already exist and be named whatever, you just specify them in the setting. Getting the help/docs tab to show up in the right place (based on user preference template selected on the help doc). Has it's own scoped CSS styling that makes the documentation readable and engaging; has some @import fonts, and also rules to make text layout look correct in PW admin (paragraphs, lists, headings, blockquotes etc.) Makes it easy for site editors to add their notes, mods/edits/enhancements to the docs (edit button - currently only enabled for Superadmin - this can be made a setting based on user feedback). Using the secondary process module will create a 'Help Docs' page under Setup where you can view all of the docs in 1 place as an accordion. (could be moved somewhere else) There is also an automated setup that can run, where it will create the field, templates, and pages for you to get started. This module is probably optimized to handle no more than 10-15 or so help pages; if you needed more than that, the Process module may need to be changed to work differently. Most sites I do need around 4-5 help pages. *If you don't want to load those extra google fonts in your admin you can modify the CSS to your needs, e.g. remove the @import and then change the few lines of css that reference those; Once there have been a few testers, I can see about adding this to the modules directory in a week or so.
    1 point
  5. A Page field allows you to add multiple pages to the field (given the right settings... Multiple Pages + ASM Select). You can also add a new Page from a Page field (assuming you've allowed that option on the field) and have it assigned to this Page field, or any other Page field. A PageTable field allows you to do the same as a Page field as I described, however if you create a Page from a PageTable field, it can only be assigned to that PageTable field... meaning Pages created from a PageTable field are not "portable" like pages created from a Page field. You can't add a page that was already created to a PageTable field (I'm not considering the edge-case whereby the pages are coming from children, which PW handles already). The nice thing about a PageTable field is its presentation capabilities which a Page field doesn't have. A Page field only has the "Custom format" labeling options, which although nice, is not as appealing as PageTable. If you want the portability of new created pages that a Page field gives you, but with the presentational capabilities of a PageTable field, that doesn't seem to exist. So, to summarize the above, should Page fields be able to have an option to present themselves like how PageTables do?
    1 point
  6. Maybe not exactly a use-case for adding additional pages, but I'm using two separate pagetables to hold applications and fully accepted applications. The pages are just moved from one to another when a application is accepted and applications can only be added to the pagetable holding the non accepted ones.
    1 point
  7. Yeah I jumped into the blog post shortly after and came up with the following: <?php $pages->addHookAfter("ProcessPageEdit::buildForm", function($event) { $form = $event->return; $page = $event->object; if ($page->template->id == 47 && $page->numChildren == 0) { $form->remove($form->getChildByName("rte_basic_2")); } });
    1 point
  8. No worries. It's not specific to PHP as you can't always guarantee a true or false response from the above code, just I know true or false is what is returned for PricessWire's checkbox values when using them in frontend templates. The actual printed value if you echo'd it would be a 1 I think if it was checked, else blank. It's always worth echoing a field to see what the actual value is, so echo $page->footerChecked in this instance.Other fields will return different values - some arrays of pages so let us know if you get stuck with anything else - there's plenty of help around the forums
    1 point
  9. this in your /site/ready.php <?php $wire->addHookAfter("ProcessPageEdit::buildForm", function(HookEvent $event){ $process = $event->object; $form = $event->return; $page = $process->getPage(); // remove field when actual page has no children if($page->numChildren == 0) { $form->remove($form->getChildByName('your_field_name')); } });
    1 point
  10. i see myself in your rewrite { } section
    1 point
  11. To get the old value(s), you can call the getChanges method like this: // If you need the old value(s) also $u->getChanges(true); Looking at your code, I see that you are assigning input from POST directly, without sanitizing. Check out ProcessWire's $sanitizer API variable. Cheers
    1 point
  12. PageArrays are internally just simple arrays and that code is retrieving that array, sorting it to fit the order of the stored id's and then setting it back to the PageArray. How usort works is quite nicely described in the php docs.
    1 point
  13. You could use wireRenderFile() inside child pages as well Just you need to create the different layouts. site/ templates/ views/ home-area1.php home-area2.php home.php For each child create a template ex: home-area1, home-area2 assign that template to every child. then in home you could use the template name for rendering the file $sections = $pages->get('template=sections'); $viewBag = getViewBag(); foreach($sections->children as $section) { $viewBag['section'] = $section; try { echo wireRenderFile("partials/home/sections/{$section->template->name}", $viewBag); } catch(Exception $e) { Debug::log($e->getMessage()); } } ?>
    1 point
  14. I would like to make a suggestion, which combines this topic with those of the cheat sheet and documentation topics, and the blog posts covering filed type definitions. I would think that someone new to processwire isn't concerned so much as how to design a front-end layout as it is how to use the power of the api as it relates to both the front-end and manipulating the supporting data. I think most people coming to processwire already have a decent grasp of HTML, PHP, etc., but lack an understanding of how to assemble all the excellent tools found within the processwire core to accomplish a desired goal. Based on the recent (past few weeks) forum topics, tutorials could cover menu creation, searching, extracting specific data from one or more pages, defining multi-language interfaces, etc. As there are many ways to approach a general objective, I would like to see specific procedures that utilize the efficiency of processwire. A great example is this tutorial by LostKobrakai. And even though there are excellent modules available that satisfy specific development requirements, there is still a need (at least for me) for a centralized location of instructional information. The resulting tutorial code samples could then be integrated into the appropriate sections of the cheat sheet and the general documentation.
    1 point
  15. I personally have some struggles with the main concepts templates, fields and how to use them in different pages. I remember making a website with a different field for each data, because different labels were needed then later I discovered that you can assign different labels for each page context. The approach for templates, fields and pages that I found easier to explain is like OOP Classes, Properties and Instances. Template = Class Field = Property Page = Instance Now you can use any UML tool to create a class diagram for a website in Processwire and explain that to every developer that knows UML.
    1 point
  16. When I need the same fields on the child pages but diffent layout, I usually go for FieldtypeSelectFile. With that field you can select a file from the PageEdit (admin) to be used as a template.
    1 point
  17. By the way your code makes smart use of pagetable and render() never thought about it to have a page accessable like this.
    1 point
  18. I'm willing to help if you need something, just ask
    1 point
  19. anyone have any thoughts or examples of tutorials for theme building in PW, just about to write mine as part of a series on envato. Ideally I'm looking to make my tutorial about making a complete theme for a simple website based from PW's site-default.
    1 point
  20. Just a update to present the whole function - may useful for others. No more ->find just some ->count 's are running in a preset scope of years...much better now. Thank you very much Jan for your example! It renders a archive navigation like 2015 (12) 2014 (4) 2013 (10) .... i changed Jan's example to sort the years in descending order. It's great a great example about the for loop (most ignored by me) function renderArchive() { //check for url segments (using URL segments for the years like /2000/ $seg1 = wire('sanitizer')->pageName(wire('input')->urlSegment1); //get homepage url for the links to build them absolut since relative wont work with URL segments $homepageurl = wire('pages')->get('/')->httpUrl; //get article root page for links $artikel_root = wire('pages')->get(1068); //get year list $out = '<h4 class="subtitle">Archiv</h4>'; $out .= '<div class="listbox1"><ul>'; //loop trow years and count pages for ($i = date('Y'); $i >= 2007; $i--) { //get start and enddate $start = "$i-01-01"; $end = "$i-12-31"; //count pages from the year $c = wire('pages')->count("template=artikel, publish_from>=$start, publish_from<=$end"); if ($c > 0) { //check if year was active $class = $i === $seg1 ? " active" : ''; //output listitem $out .= '<li class="'.$class.'"><a href="'.$homepageurl.$artikel_root->name.'/'.$i.'/">'.$i.' ('.$c.')</a></li>'; } } //close list $out .= '</ul></div>'; return $out; } Best regards mr-fan
    1 point
  21. ProcessWire tracks changes on properties, so you could do something this: // After submitting your form with POST, set the new values to your user object $u = $users->get('myUser'); $u->of(false); $u->set('field1', $sanitizer->text($input->post->field1)); $u->set('field2', $sanitizer->text($input->post->field2)); $u->set('field3', $sanitizer->text($input->post->field3)); // Now assume only field2 and field3 changed $u->getChanges(); // --> Returns you array('field2', 'field3'); // If you need the old value(s) also $u->getChanges(true); $u->save(); Hope it helps! Cheers
    1 point
  22. Bravo that worked perfectly thank you very much again Martijn.
    1 point
  23. How the class is written now it don't has access to WireMailSmtp, as WireMail is the parent class and not WireMailSmtp. To make it work with not known methods it needs a total rewrite, if even possible. But there's a work around. // This don't work with methods not know by WireMail $mail = wireMail(); // When you instantiate WireMailSmtp yourself it all works $mail = $modules->get('WireMailSmtp');
    1 point
  24. thanks for your reply, Tom. I think that pointed me the right way. I am now testing grouping of selectors. Your suggestion combined with a second group should to the job. (Hopefully it doesnt fail proof). Even if it does not fullfill a hundred percent it is an improvement So this is my selector (field1|field2~=phrase-full),(field1|field2=phrase-segment1),(field1|field2=phrase-segment2), ...
    1 point
  25. Hello, I recently came across this. However I used a very different method than the example I'm going to attempt because I was matching tags. Basically I would get a match on "Disability Act" but not "How to help with Disability". Because it was looking for something that contained all the connectives "How to help with" however as the search engine, I was only interested in the "Disability" part. For this I would try (please bare in mind I don't know the templates/fields): $selector = ""; $search = explode(" ", $input->get->search); foreach($search as $result) { $selector .= ", (field1|field2=$result)" } $pages->find("template=skyscraper" . $selector); However this wouldn't take put the result higher up if it had "Thomas" in the address and the area as "NYC" it would pick one and return results based on that. I would love to know how to do the search based on most matched phrases. However I have no idea how to do that. Maybe someone far smarter than me could tell you how to do that in ProcessWire
    1 point
  26. Image upload could be the following 500 error? "POST /index.php?it=/admin/page/edit/&id=1004&InputfieldFileAjax=1&{args} HTTP/2.0" 500 228 No time to take a closer look yet... But looks PW@caddy seems to be fast Caddyfile https:example.com { root public_html fastcgi / 127.0.0.1:9000 { # ext .php .module ext .php } internal /forbidden rewrite { r /\. to /forbidden } rewrite { r /(COPYRIGHT|LICENSE|README|htaccess)\.txt to /forbidden } rewrite { r ^/site(-[^/]+)?/assets/(.*\.php|backups|cache|config|install|logs|sessions) to /forbidden } rewrite { r ^/site(-[^/]+)?/install to /forbidden } rewrite { r ^/(site(-[^/]+)?|wire)/(config(-dev)?|index\.config)\.php to /forbidden } rewrite { r ^/((site(-[^/]+)?|wire)/modules|wire/core)/.*\.(inc|module|php|tpl) to /forbidden } rewrite { r ^/(site(-[^/]+)?|wire)/templates(-admin)?/.*\.(inc|html?|php|tpl) to /forbidden } # GLOBAL rewrite { r .* ext / to /index.php?it={path}&{query} # to /index.php?it={path}&{query}&{args}#{frag} # to /index.php?it={uri}&{query} # to {uri} {uri}/ /index.php?it={uri}&{query} } log logs/access.log { rotate { size 50 age 7 keep 5 } } errors { log logs/error.log { size 50 age 7 keep 5 } } } Next release will have some improvements to replace like that to {uri} {uri}/ /index.php?it={uri}&{query} => file if exists OR directory if exists OR rewrite to index.php... Maybe some PW directories should be moved to make htaccess file / nginx | caddy rewrite easier and much shorter (disallowed directories could be moved to a sub directory?).
    1 point
  27. @benbyf ..or use both if character limit allows?
    1 point
  28. For question #1, there's a less complicated way to go about it. Create a Page field called "Favorites" (or "Subscriptions"). Templates allowed for this field should be: episode, series, and whatever else can be favorited. Add this Favorites field to the User template. Program the feature as needed. For question #2, the approach you outlined is pretty correct and the ProcessWire way of doing things (or you could also use Options Fieldtype, but I don't prefer it). I personally call it "Options" instead of "Tools" and pluralize the option types (Languages instead of Language, Durations instead of Duration). Then create Page fields as necessary.
    1 point
  29. You are saying that building custom applications in PW with the "everything is page"-mantra has its limitations - and that's right! No one has said, that every possible application can and should be built with PW-pages. PW is a Content Managment Framework, and for most of the contents you need for the web, its possibilities are more than enough. I think it is not fair by judging over PW while developing an ecommerce-application as your first application. Look at most of online-shopping suites like Magento or Prestashop, how difficult they were to develop just with php(-frameworks). Some applications are not best suited for PW (or any other CMS), at least with not building some helping modules or components, which could make it easier for plug the application together. Just another thought: would you have considered any other CMS with its built-in editing & API to develop an ecommerce solution on top of that?
    1 point
  30. As for your wish request. It is already possible to track changes, what -> old -> new value. $user->setTrackChanges(true); wire()->addHookAfter("User::changed", null, function($event){ $what = $event->arguments("what"); $old = $event->arguments("old"); $new = $event->arguments("new"); echo "changed: " . $what . " - " . $old . " -> " . $new; });
    1 point
  31. the value of a repeater is pageArray, so getNext() should work. What value are you using as the parameter? Edit: Ok, quickly tested, and everything works as expected. I will post here my test so you can analyze and make sure that you are using it the right way: $repeaterArray = $page->repeater; $firstElement = $repeaterArray->first(); echo $repeaterArray->getNext($firstElement); //returns successfully the second element echo $firstElement->next(); //also returns the second element
    1 point
×
×
  • Create New...