-
Posts
5,007 -
Joined
-
Days Won
333
Everything posted by Robin S
-
Assumes "categories" is a multiple Page Reference field and that you have a hex colour defined on each category page: $wire->addHookAfter('ProcessPageListRender::getPageLabel', function(HookEvent $event) { $page = $event->arguments(0); if($page->template == 'accommodation') { $out = ''; foreach($page->categories as $category) { $out .= "<span class='uk-label' style='background-color:$category->hex_colour'>$category->title</span> "; } $out .= $page->title; $event->return = $out; } });
-
Swopping an existing page to be "home" ...
Robin S replied to Greg Lumley's topic in General Support
There's no simple way because the home page is a special case in PW, but some similar topics with suggestions: -
Please do, I'd be very interested to read that! It seems like this should be doable via a module in PW. I have a work-in-progress module that does something like this. It's not complete and haven't looked at it a while but it seemed like a promising avenue at the time. I think if the concept could be illustrated in a module then Ryan might see the benefits and then hopefully incorporate the features into the core. Seeing as you've clearly spent some time thinking about these issues, would you mind writing up a wishlist of what things you think PW should handle via files for the sake of version control? Fields and templates are the obvious things but you also mentioned translations which I wouldn't have thought of (I only work on single language websites) so it would be great to have a comprehensive list of problem areas for version control. Thanks in advance! ?
- 66 replies
-
- 9
-
-
- developing
- working with pw
-
(and 1 more)
Tagged with:
-
Preset of template in template-pulldown (when creating a new page)
Robin S replied to cabrooney's topic in General Support
ProcessPageAdd preselects the template according to these principles: If there is already one or more child pages under the parent then it preselects the same template as used by the most recently added child page. If there are no child pages it preselects the same template as used by the parent page. But if that template isn't allowed to be used under the parent page then no template is preselected. So probably you recently added a page using the template that is only used in 5% of the cases, or that is the template of the parent page. You can force a particular template to be preselected in a couple of ways. 1. You can add a "template_id" GET variable to the URL of the "Add New" page. Example: "/processwire/page/add/?parent_id=1234&template_id=29" This might be a good approach if you are constructing your own custom link to the "Add New" screen but not so useful if you are just adding a new page via the standard PW admin. 2. You can use a hook in /site/ready.php to set a template_id GET variable to $input: // Before the ProcessPageAdd form is built $wire->addHookBefore('ProcessPageAdd::buildForm', function(HookEvent $event) { $input = $event->wire()->input; // Get the parent page the new page is being added under $parent_id = (int) $input->get('parent_id'); $parent = $event->wire()->pages->get($parent_id); // Return early if a single parent page isn't available or valid if(!$parent->id) return; // Do whatever check you need to identify if this is the parent you want to target if($parent->template == 'home') { // Get the template you want to be preselected $child_template = $event->wire()->templates->get('basic_page'); // Set the template ID to the "template_id" GET variable $input->get->template_id = $child_template->id; } }); -
@Richard Jedlička @wbmnfktr You can set a response code in your hook like this: http_response_code(400); So you can set 400, 307, or whatever you need. https://www.php.net/manual/en/function.http-response-code.php
-
Need for a InputfieldSubmit->disable() call?
Robin S replied to J_Szwarga's topic in Module/Plugin Development
I just tested in PW 3.0.191 Result: No wrapping <a> tag, button is disabled, button is visually identifiable as disabled, works as expected. -
MarkupAdminDataTable::action() is a method that you call, not a property that you set. You would call the method like this: $table->action(['Home' => './']);
-
Select Once Per Table: store extra information for selected pages
Robin S replied to Robin S's topic in Modules/Plugins
See here:- 15 replies
-
- module
- extra information
-
(and 3 more)
Tagged with:
-
Select Once Per Table: store extra information for selected pages
Robin S replied to Robin S's topic in Modules/Plugins
Added in v0.2.1- 15 replies
-
- 1
-
-
- module
- extra information
-
(and 3 more)
Tagged with:
-
$page->path always has trailing slash in spite of template settings
Robin S replied to DrQuincy's topic in General Support
The trailing slash setting is something that applies to URLs rather than paths, i.e. $page->url rather than $page->path. Related GitHub issue with response from Ryan: https://github.com/processwire/processwire-issues/issues/273 -
Hi @adrian, thanks for the report. Please update to v0.4.4 and it should work.
-
Select Once Per Table: store extra information for selected pages
Robin S replied to Robin S's topic in Modules/Plugins
I've added support for "Page (Autocomplete Single)" columns in v0.2.0.- 15 replies
-
- 3
-
-
- module
- extra information
-
(and 3 more)
Tagged with:
-
How do you deal with multiple files with the same names in your IDE
Robin S replied to Ivan Gretsky's topic in Wireframe
Not a solution for VSCode but just for comparison... PhpStorm automatically adds the parent folder to the tab label as soon as two files are open with the same name. It's a nice feature. -
Yes, it's InputfieldTextTags: https://processwire.com/blog/posts/pw-3.0.177/
-
Select Once Per Table Adds a setting to "Select", "Page (Select)" and "Page (Autocomplete Single)" columns in a ProFields Table field so that each option can only be selected once per table. Requires the ProFields Table module. There could be a number of situations where this module might be useful, but perhaps the primary situation is when you want to store extra information for pages that are selected in a Page Reference field. So instead of using a Page Reference field like this... ...you could use a ProFields Table field together with Select Once Per Table to store extra information for each selected page like this... The module ensures that pages/options that are already selected in the Table field are disabled as you add new rows or edit existing rows. Configuration To enable the module for any "Select", "Page (Select)" or "Page (Autocomplete Single)" column in your Table field, edit the column settings and add selectOnce=1. https://github.com/Toutouwai/SelectOncePerTable https://processwire.com/modules/select-once-per-table/
- 15 replies
-
- 11
-
-
-
- module
- extra information
-
(and 3 more)
Tagged with:
-
I'm not clear on how this relates to the Connect Page Fields module. Could you explain a bit more about how the module is involved in the error?
-
ProcessPageEditImageSelect Problem with Repeaters
Robin S replied to Orkun's topic in General Support
@Orkun, in case you missed it, Ryan has fixed this issue: https://github.com/processwire/processwire-issues/issues/1482 -
ProcessPageEditImageSelect Problem with Repeaters
Robin S replied to Orkun's topic in General Support
I see what you mean. It does seem like a bug that Ryan should take a look at. Edit: GitHub issue opened. https://github.com/processwire/processwire-issues/issues/1482 -
ProcessPageEditImageSelect Problem with Repeaters
Robin S replied to Orkun's topic in General Support
Answer to a similar question here: -
In your template file: if($input->get('print')) { // Your special print-friendly markup here } else { // Your normal markup here } In your normal markup include a link to the print-friendly view: <a href="<?= $page->url ?>?print=1">Print-friendly view</a> If you want to automatically open the browser's print dialog you can include this in your print-friendly markup: <script> window.print(); </script>
- 1 reply
-
- 1
-
-
I don't think $event->replace = true is supposed to have any effect on whether an "after" hook fires for a method - it just means that the code inside the hooked method will not execute. If you're trying to stop subsequent hooks from firing then have a look at $event->cancelHooks (https://processwire.com/api/ref/hook-event/)
-
Issue using OR in selector with Page->Closest method
Robin S replied to MarcC's topic in General Support
I can confirm this. It's like the order of the field names is treated as if they are in order of priority, but I don't think this is expected - all the fields in the OR condition should be treated equally. Could you please open a GitHub issue so Ryan is alerted? https://github.com/processwire/processwire-issues/issues- 1 reply
-
- 1
-
-
A few suggestions: 1. It's best to match using a page's ID rather than its name, because the ID is globally unique but the name is not. So instead of... $pages->find("template=Technique, relation_technique_substance.relation_technique_substance_select=$page->name") ...you can do... $pages->find("template=Technique, relation_technique_substance.relation_technique_substance_select=$page->id") ...and because the string value of a Page object is its ID it's typical to do... $pages->find("template=Technique, relation_technique_substance.relation_technique_substance_select=$page") 2. You don't need to create a PageArray and add pages to it because $pages->find() already returns a PageArray. So this... $techniques = new PageArray(); $selector_tech = "template=Technique, relation_technique_substance.relation_technique_substance_select=$page->name"; $techniques->add($pages->find($selector_tech)); ...can be simplified to... $techniques = $pages->find("template=Technique, relation_technique_substance.relation_technique_substance_select=$page"); 3. PageArrays have a count() method/property, so rather than... if (sizeof($techniques) > 0) { ...try... if ($techniques->count) { 4. To answer your main question, the value of a Repeater field is a (Repeater)PageArray so you can use ->find($selector) to search within it. foreach ($tech->relation_technique_substance->find("relation_technique_substance_select=$page") as $relation_technique_substance) { Now any Repeater items where relation_technique_substance_select does not include $page will be excluded.
- 1 reply
-
- 1
-
-
It's working inside a Repeater for me. This module works via JavaScript, and only with the inputfield. You're showing an SQL error but this module won't be anything to do with that. If a totally different inputfield is also affected then it's unlikely to be anything to do with this module.