Leaderboard
Popular Content
Showing content with the highest reputation on 11/25/2013 in all areas
-
Template Notes Adds a "Help" tab to pages for notes and instructions on the current template used. You can add content by simply putting a html or markdown file in /site/templates/notes/ the module will automatically load that file if it finds one and adds a "Help" tab to the page edit form. Name the files using the template name. You can use html or markdown to write the help text. - /site/templates/notes/[tplname].html - /site/templates/notes/[tplname].md To style the content you can specify a custom css file url you add to the module settings. http://modules.processwire.com/modules/template-notes/ https://github.com/somatonic/TemplateNotes This module was quickly written after seeing a wish-list request by Joss http://processwire.com/talk/topic/5016-help-tab-for-template/6 points
-
5 points
-
Basically, this would be an optional tab in the template administration form. The tab would have a nice big textarea (perhaps with editor) where you can write documentation for the specific template. Then, when the user creates a new page with that template, they have a Help tab where they can see all that nice help. This can be useful when you need lots of explanations for the fields, but want to keep the form as uncluttered as possible, so may not want to have descriptions displayed on every field. It would also allow plenty of space for talking about writing styles for particular templates, including lists of key phrases for SEO. Joss4 points
-
4 points
-
Template Cache and $page->render($options) If you ever use the $page->render() to render out partials (of another page using its template file) and use template cache for the pages you're going to render and the page where you render it, it will create a cachefile. So if you go to that previously rendered and cached page, it will render that partial. If the page is accessed before a cache is created, it will cache this one and render that in as the partial, so kinda turned around. Funny effect. And many mmms and oaaahhhs To get a better understanding what's happening read on. Simple example code from a list page to render partials of articles (likely) // from the list pages template $markup = ''; foreach($products as $key => $child) { $markup .= "<dl>"; $markup .= $child->render(array('isOverview' => true, 'class' => $class)); $markup .= "</dl>"; } echo $markup; And in the template of the article // in article template file if(isset($options['isOverview']) && $options['isOverview'] == true) { // render small partial $class = $options['class']; $markup = "<dd class='$class'> <h4>$page->title</h4> <p>$page->summary</p> <a href='$page->url'>details</a> </dd>"; } else { // render complete article $markup = "<div class='product-details'> <h1>$page->title</h1> $page->body </div>"; } // output echo $markup; So now the render call $markup .= $child->render( array('isOverview' => true, 'class' => $class) ); in the list template will cache the page it renders (the small view of it). Thus if you access the page directly it will serve the cached small view of it. Ups. Solutions This is without specifying a different template file in the first argument in the render(). The effect doesn't happen when you, let's say create a new template file (ie article-small.php) and use that to render the page. Since this new template file is not connected to the template in PW it also has no cache for that render. To show what I mean is the following with the first argument the file you want the view to render. $markup .= $child->render("product-small.php", array("isOverview" => true, "class" => $class)); Still following me? Ok there's also another method to not allow a cache file to be created. There's a default options set in the render() in PW. Bingo! allowCache is what we can also use. $markup .= $child->render("product-small.php", array( "allowCache" => false, "isOverview" => true, "class" => $class )); And everything's back to normal. Just wanted to write down a little thing, as I stumbled over this recently, to scatter some keywords about this here . I think this isn't really documented somewhere but I thought it was maybe mentioned by Ryan in a thread about when he added this feature: http://processwire.com/talk/topic/3145-multiple-views-for-templates/page-2?hl=%2Brender+%2Bcaller#entry32876. Edit: Zaaakkkk and it's in Google 9 minutes !2 points
-
Joss, you can get the page number with $input->pageNum, so: if ($input->pageNum < 2) { // Show the thing }2 points
-
2 points
-
Menu Builder As of 29 December 2017 ProcessWire versions earlier than 3.x are not supported Modules Directory Project Page Read Me (How to install, use, etc..) For highly customisable menus, please see this post. If you want a navigation that mirrors your ProcessWire page tree, the system allows you to easily create recursive menus using either vanilla PHP or Soma's great MarkupSimpleNavigation. In some cases, however, you may wish to create menus that: 1. Do not mirror you site's page tree (hirarchies and ancestry); and 2. You can add custom links (external to your site) to. That is primarily where Menu Builder comes in. It is also helpful if you: 3. Prefer creating menus via drag and drop 4. Have a need for menus (or other listings) that will be changing regularly or that you want to allow your admin users to edit. The issue of custom menus is not new here in the forums. The difference is that this module allows you to easily create such menus via drag and drop in the Admin. Actually, you can even use it to just create some list if you wanted to. In the backend, the module uses the jQueryUI plugin nestedSortable by Manuele J Sarfatti for the drag and drop and is inspired in part by the WP Custom Menu feature. Please read the Read Me completely before using this module. For Complex or highly-customised menus, it is recommended to use the getMenuItems() method as detailed in this post. Features Ability to create menus that do not mirror your ProcessWire Page Tree hierarchy/structure Menus can contain both ProcessWire pages and custom links Create menu hierarchies and nesting via drag and drop Easily add CSS IDs and Classes to each menu item on creating the menu items (both custom and from ProcessWire pages) or post creation. Optionally set custom links to open in a new tab Change menu item titles built from ProcessWire pages (without affecting the original page). E.g. if you have a page titled 'About Us' but you want the menu item title to be 'About' Readily view the structure and settings for each menu item Menus stored as pages (note: just the menu, not the items!) Menu items stored as JSON in a field in the menu pages (empty values not stored) Add menu items from ProcessWire pages using page fields (option to choose between PageAutocomplete and AsmSelect [default]) or a Selector (e.g. template=basic-page, limit=20, sort=title). For page fields, you can specify a selector to return only those specified pages for selection in the page field (i.e. asm and autocomplete) For superusers, optionally allow markup in your menu titles, e.g. <span>About</span> Menu settings for nestedSortable - e.g. maxLevels (limit nesting levels) Advanced features (e.g. add pages via selector, menu settings) currently permissible to superadmins only (may change to be permission-based) Delete single or all menu items without deleting the menu itself Lock down menus for editing Highly configurable MarkupMenuBuilder - e.g. can pass menu id, title, name or array to render(); Passing an array means you can conditionally manipulate it before rendering, e.g. make certain menu branches visible only to certain users [the code is up to you!] Optionally grab menu items only (as a Menu object WireArray or a normal array) and use your own code to create custom highly complex menus to meet any need. More... In the backend, ProcessMenuBuilder does the menu creation. For the frontend, menus are displayed using MarkupMenuBuilder. Credits In this module's infancy (way back!), I wanted to know more about ProcessWire modules as well as improve my PHP skills. As they say, what better way to learn than to actually create something? So, I developed this module (instead of writing PW tutorials as promised, tsk, tsk, naughty, naughty!) in my own summer of code . Props to Wanze, Soma, Pete, Antti and Ryan whose modules I studied (read copied ) to help in my module development and to Teppo for his wonderful write-up on the "Anatomy of fields in ProcessWire" that vastly improved my knowledge and understanding of how PW works. Diogo and marcus for idea about using pages (rather than a custom db table), onjegolders for his helpful UI comments, Martijn Geerts, OrganizedFellow, dazzyweb and Mike Anthony for 'pushing me' to complete this module and netcarver for help with the code. Screens1 point
-
http://css-tricks.com/introducing-scut-new-sass-utility-library/ http://davidtheclark.github.io/scut/ This is so in tune with the spirit of Processwire I thought I have to make a post. In the CSS Tricks article comments you can find some other people, who are building similar libraries.1 point
-
1 point
-
It does have one interesting advantage - portability. It means you can write pretty comprehensive help files, and then just copy them into a new installation, editing them a bit to match the new template. Since certain things get repeated between sites, like news, this makes sense.1 point
-
Even works on my old Bootwire Admin Theme! Soma, that is perfect. Get it on the Modules immediately! Now, where is my old copy of FrontPage 98 so I can knock up some quick help files? (Actually, I still have on my shelf a copy of Corel Webmaster Suite and Adobe Go Live, which I don't think I ever used) Thanks Soma!1 point
-
1 point
-
1 point
-
Hello all, I'm pretty new to PW, coming over from the Joomla world. In J! there is a truncate method that does just that: truncate a piece of text. The problem with implode() or substr() is that it doesn't take html tags into account. So if I wanted to truncate a text that comes from a wysiwyg input, I might loose closing tags which can result in display/validation errors. So basically my question is: Does PW API provide a truncate method and if not what are your favorite ways to get this done? Thanks Gerhard EDIT: There seems to be a very popular PHP function for Truncate string while preserving HTML tags and whole words. And a slick jQuery plugin to limit text and expand to full length on click readmore: readmore.js1 point
-
I think this should work but you can also do $user->user_app->remove($page);1 point
-
Sometimes I use a textarea field and put key | value pairs on each line. Those can be explode("\n", $page->textarea) in your template.1 point
-
If there was a way for us to make PW automatically reassign the $user variable after login, we'd do it. It's not technically possible for PW to do that (it's a matter of variable scope). That's why you'd have to do what Adrian suggested and assign the $user variable yourself from the result of login(). However, what Soma was getting at before he gave up was even better because it wouldn't trash the $user variable if the login failed. So something like this might be ideal: $u = $session->login($username, $pass); if($u) { $user = $u; echo "logged in"; }1 point
-
hey Joss - maybe see if this is better... still untested: <? function events() { // get all of the events $events = wire("page")->events; //gets the repeater field $years = array(); $out =""; // find the array of years for all events foreach ($events as $event) { $years[]= date("Y", $event->getUnformatted("event_start_time")); // add properties event_year and event_month to the $event object $event->event_year = date("Y", $event->getUnformatted("event_start_time")); $event->event_month = date("m", $event->getUnformatted("event_start_time")); } $years = array_unique($years); asort($years); // for testing // print_r($years); // print_r($events); foreach($years as $key => $year) { // Output the year $out .="<h2>{$year}</h2>"; // find the array of events this year and put into new array $year_events $year_events = $events->find("event_year=$year"); // print_r($year_events); // loop through the events for this year and add the months to the array $months = array(); foreach ($year_events as $year_event) { $months[]= date("m", $year_event->getUnformatted("event_start_time")); } $months = array_unique($months); asort($months); // print_r($months); // loop through the months and find events for the month foreach($months as $key => $month) { // Output the month as a number $out .="<h3>{$month}</h3>"; // filter only the events for this month, from the $year_events array. $month_events = $year_events->find("event_month=$month"); // print_r($month_events); foreach($month_events as $e) { $out .="<p>{$e->event_who}</p>"; } // end foreach events for this month } // end foreach months } // end foreach years echo $out; } ?> *maybe joss or a moderator could mark this as best answer?1 point
-
That's a good observation. That must have started when I added the version checking code to GitHub. It now updates each module page with the date of the last time it checked the version. The problem here is that it's also updating the 'modified' timestamp of those pages, which is in turn appearing in the feed that ModulesManager uses. The good news is that an option was recently added to the core (on dev) that can prevent this: $pages->save($page, array('quiet' => true)); That 'quiet' option tells it not to update the modified date or user, which will be perfect for this particular situation. I'll plan to get the modules directory updated with this option soon.1 point
-
What Soma said. ProcessWire promises the Fieldtype interface that it will have an actual Page to work with (one that has an ID and a place to store files, etc.). It could be reduced to 1 step by automatically creating that page whenever you click "new", but you'd likely have plenty of accidental pages as a result. Also, as a best practice, GET requests should not make changes to database or disk, so it's always preferable to submit a form before creating a new asset.1 point
-
This works: https://gist.github.com/outflux3/7608974 let me know if it works for you!1 point
-
Edit: I was toofast, try to use the $config->url or $config->path properties. (Check cheatsheet.processwire.com for more details. )1 point
-
I'd try to clear the browser cache (and logout/login again), and/or update to latest stable version, and/or run some sort of browser dev tool to see possible JS errors / warnings. (and maybe even trying to access the backend with a different browser altogether)1 point
-
Since you are pulling them right out of $_GET (or $input->get), you should filter and sanitize them before doing your http_build_query. $types = array( 'limit' => 0, 'my_string_var' => '', 'my_int_var' => 0, ); $params = array(); foreach($types as $name => $type) { $value = $input->get->$name; if($value === null) continue; // not specified, skip over if(is_string($type)) $params[$name] = $sanitizer->text($value); // sanitize as string else $params[$name] = (int) $value; // sanitizer as int } if(empty($params['limit'])) $params['limit'] = 10; // set a default $new_query_string = http_build_query($params);1 point
-
This is a good exercice to getting know the ProcessWire API A good overview how you can find pages and output content of fields: http://processwire.com/api/variables/pages/ And here's one solution among others, how you would do your menu: <ul class="blue nav" id="css3-menu"> <li class="dropdown"> <a class="dropdown-toggle_" data-toggle="dropdown" href="<?php echo $pages->get('/services/')->url; ?>">Services</a> <ul class="dropdown-menu"> <?php //We need to loop over the children of Services and output their links $children = $pages->get('/services/')->children(); foreach ($children as $child) { echo "<li><a href='{$child->url}'>{$child->title}</a></li>"; } ?> </ul> </li> </ul>1 point
-
Ryan, I love it! Soma, I absolutely get what’s your point. Especially for editors it would be a very comfortable solution to deal with repeatable elements of different templates. Maybe their should be a kind of helper field type, that just allows you to manage a page’s child pages as repeatable elements, so editors don't have to deal with creating child pages manually. Its input field setup in the page edit process would look just like ryan’s here, showing blocks with the child pages’ fields. The editor could choose from the allowed templates for new child pages. And in templates the field would directly provide the page array like in repeatable elements. Of course it just would be a kind of shortcut for stuff that could be done manually already. Right now I’m working on a project, where such a thing would be pretty useful.1 point
-
Awesome! Yeah first! Now going to look at video.... Edit: Looks really great! Thank you for this preview! For sure very useful. Now my question. Would it be any way possible to have to be able define multiple "block" templates (with different fields each) for the repeater field? Then when adding a new item, it would ask for the block template to select first. Pretty much the same as it is now, just with variable templates. I can imagine it would require something complete different concept/codewise. It's just what I kinda "expected" from (the) repeatable page element, so I don't have to use child pages anymore. It can be very handy to be able to define "blocks" that can be chosen from, to build a page. TItle, Video, Text-Image, Linklist, Text. Do you see a good way to add such "variable blocks" feature to PW through a module, much similar like this one? Maybe they're also just invisible childpages that are editable and sortable via the parent page's block field. Just blah blah, I don't really know what all need to be considered. Have you implemented this repeater using hidden pages?1 point