Leaderboard
Popular Content
Showing content with the highest reputation on 02/04/2019 in all areas
-
Happy to announce that i just gave birth to another Processwire Website. ? This one has an event calendar, which was easy to build with Processwire. bridgesmusikverbindet.de4 points
-
Perhaps you have auto-prepended and/or auto-appended template files in your /site/config.php, in which case you would want to use the $options array to override those when rendering the page, e.g. foreach ($pages->find("template=article") as $article) { $content .= $article->render('teaser.php', ['appendFile' => null]); }3 points
-
On second thought.. Turns out module development is so simple due to the elegant API, so I went ahead and wrote myself a module: <?php namespace ProcessWire; class RenderWith extends WireData implements Module { public static function getModuleInfo() { return [ 'title' => 'RenderWith', 'summary' => 'API extention for rendering pages with different templates.', 'version' => 1, 'autoload' => true ]; } public function ready() { $this->addHook('Page::renderWith', $this, 'renderWith'); $this->addHook('PageArray::renderWith', $this, 'renderManyWith'); } public function renderWith($event) { $page = $event->object; $template = $event->arguments(0); $event->return = wireRenderFile($template, ["item" => $page]); } public function renderManyWith($event) { $pages = $event->object; $template = $event->arguments(0); $content = ""; foreach ($pages as $page) { $content .= wireRenderFile($template, ["item" => $page]); } $event->return = $content; } } No idea if I am breaking any design principles or anything here, so viewer discretion is adviced.3 points
-
Hi @ryan, could you please add some more detailed documentation for the $page->render() method to the API docs? Currently the details are quite minimal (the method doesn't have it's own page but just a short entry on the $page documentation) and doesn't cover all the options that you describe in this post: I guess the docs for $page->render() need to somehow pull in the PhpDoc comments from PageRender::renderPage().3 points
-
Hey Peter - you can customize in the settings exactly how you want - site wide, template wide and even by page IIRC. However, you might want to check out: https://github.com/wanze/SeoMaestro @Wanze looks to have done a beautiful job on this. @GhostRider - you might also want to check that new module out.2 points
-
Welcome to the PW forums @Anders! There are many different ways you could do this and at the end of the day it comes down to personal preference. Myself, if this was a one-off listing of teasers that wasn't to be used on other templates I would tend to build the markup directly in the template file and not render any other files. And if it was a listing that was to be used in several template files I would tend to render a file that looped over multiple pages and I would pass those pages to the rendered file. I prefer to output markup directly and make use of the Markup Regions feature, but to keep with your case of populating a $content variable it would be something like this: $content .= $files->render('teasers', ['items' => $pages->find("template=article")]); BTW, the wireRenderFile() function is sort of obsolete as far as I can see because it is just an alias for $files->render(). But if you wanted to render a page with something similar to your example... ...then you could look at the (largely undocumented) $page->render() method. The best resource that I know of for this method is Ryan's post here: Also you can read the comments for PageRender::renderPage() in /wire/modules/PageRender.module (which is what $page->render() calls behind the scenes). So you could do something like: foreach ($pages->find("template=article") as $article) { $content .= $article->render('teaser.php'); }2 points
-
1 point
-
@Robin S Yeah, that solved it. Thanks a lot - really appreciate it!1 point
-
Just in case, I use those alias to install or upgrade my installs : # ProcessWire Wireshell bash alias # grab and install the latest ProcessWire development version from the latest commit alias pwnew='wireshell new --sha=`git ls-remote https://github.com/processwire/processwire refs/heads/dev | cut -f1`' # upgrade to the latest ProcessWire development version from the latest commit alias pwup='wireshell upgrade --sha=`git ls-remote https://github.com/processwire/processwire refs/heads/dev | cut -f1`' https://gist.github.com/flydev-fr/addcf54fa8348de20115d3c1314ddb3d1 point
-
RedBeanPHP is a simple and easy-to-use ORM, and this module is a lightweight ProcessWire wrapper and/or loader for it. The main task of the module is loading and setting up RedBeanPHP with database credentials from $config. There are some config settings for defining how RedBeanPHP should behave, and the module also exposes some often-used methods, but that's just about it. For more details (including a rant about why one might prefer separate ORM in some cases), take a look at the README file. Please note that, for almost all use cases, the data modeling features of ProcessWire are much better choice than a separate database structure of your own, but in those rare cases where that's not the situation, it's good to have options. This module was a side product of one of my own projects, and I thought I might as well share it with you folks. You can grab the module from GitHub: https://github.com/teppokoivula/RedBeanPHP.1 point
-
Quick update: version 2.0.0 of this module is now available via GitHub. This version includes updated RedBeanPHP library, various new config settings (including the ability to disable automatic setup of RedBeanPHP, and an option for choosing one of the trimmed down library versions with support for specific database type only), and various other updates to the module. I've also dropped support for PW 2.x and PHP < 5.4, and updated module requirements accordingly. For pre-3.x or pre-PHP 5.4 users the legacy branch still contains old version of the module.1 point
-
@adrian and @thetuningspoon thanks! ? Needed some tweakage as FieldsetPage, although based on Repeater, only has one page, not a number of child pages under the repeater page, in admin. Got it working with: /** * Creates a fieldsetpage field with associated fieldgroup, template, and page * * @param string $repeaterName The name of your fieldsetpage field * @param string $repeaterFields List of field names to add to the fieldsetpage, separated by spaces * @param string $repeaterLabel The label for your fieldsetpage * @param string $repeaterTags Tags for the fieldsetpage field * @return Returns the new FeildsetPage field * */ public function createFieldsetPage($repeaterName,$repeaterFields,$repeaterLabel,$repeaterTags) { $fieldsArray = explode(' ',$repeaterFields); $f = new Field(); $f->type = $this->modules->get("FieldtypeFieldsetPage"); $f->name = $repeaterName; $f->label = $repeaterLabel; $f->tags = $repeaterTags; $f->save(); //Create fieldgroup $repeaterFg = new Fieldgroup(); $repeaterFg->name = "repeater_$repeaterName"; //Add fields to fieldgroup foreach($fieldsArray as $field) { $repeaterFg->append($this->fields->get($field)); } $repeaterFg->save(); //Create template $repeaterT = new Template(); $repeaterT->name = "repeater_$repeaterName"; $repeaterT->flags = 8; $repeaterT->noChildren = 1; $repeaterT->noParents = 1; $repeaterT->noGlobal = 1; $repeaterT->slashUrls = 1; $repeaterT->fieldgroup = $repeaterFg; $repeaterT->save(); // Create the admin/repeaters page (different to standard repeaters) // add more options to the page if you prefer $repeaterPage = new Page(); $repeaterPage->of(false); $repeaterPage->template = 'admin'; $repeaterPage->name = "for-field-" . $f->id; $repeaterPage->title = $f->name; $repeaterPage->parent_id = $this->pages->get("path=/admin/repeaters/"); $this->pages->save($repeaterPage); // Associate the FieldsetPage field with the new admin/repeater page $f->parent_id = $this->pages->get("name=$repeaterPage")->id; $f->template_id = $repeaterT->id; //Now, add the fields directly to the FieldsetPage field foreach($fieldsArray as $field) { $f->repeaterFields = $this->fields->get($field); } $f->save(); return $f; } and example usage: $fsPageName = "fspage_widget"; $fsPageFields = "widget_title"; $fsPageLabel = _("My Widget"); $fsPageTags = "widget"; $f = $this->createFieldsetPage($fsPageName,$fsPageFields,$fsPageLabel,$fsPageTags);1 point
-
Hey @ryan. I'm wondering if it would be possible to set up a repository for the new site, so that we could submit pull requests and report issues there? Personally I'd still like to suggest some usability / accessibility related changes and fixes, but currently that's a bit difficult to do – and it basically requires me reporting the issue, and then you having to figure out how to fix it for the site. If there was a repository, we could a) reliably keep track of issues that have been fixed or closed for other reasons (avoiding duplicate reports), b) submit changes so that you don't have to do everything yourself, and c) experiment with the site with ease. If the site has features that can't be made public, a repository containing partial site profile would of course do, but the best solution would imho be a full site that we can install locally, makes changes to, build, test for regressions, and so on. Or perhaps you could only share access on a case-by-case basis, since even GitHub now supports private repositories? ? Thanks for considering this!1 point
-
This week we take a closer look at the upcoming ProMailer module with a lot more details and screenshots. Plus an update on next steps with the new website and development schedule in the weeks ahead— https://processwire.com/blog/posts/promailer-preview/1 point
-
Maybe there should be a note in the plugin settings that using Checking EU is sending personal IP data to extreme-ip-lookup.com (USA?) and restcountries.eu which might be breaking GDPR law (Server location?), when checking that option. [OFFTOPIC] Tracy: I only use parts of it, especially using bd() causes an Uncaught Error: Call to undefined function bd - had no time to figure that out yet [/OFFTOPIC] ... your question replied the quick 'n dirty way: echo "|" . ($this->get_user_ip_addr()) . "|"; returns |::1| The notice only appears when first visiting the page, it is gone after a refresh and visiting other pages of that site. (PHP 7.1) My solution for now: Unchecking the EU feature.1 point
-
Why is there no simple preview button? For simple websites I dont need the features of the ProDrafts. I think, it should be in the core.1 point