-
Posts
5,008 -
Joined
-
Days Won
333
Everything posted by Robin S
-
No, doing this would only allow the exact URL segment 'category'. Instead, don't place any restrictions on the segment in the template settings and do your segment validation inside the 'news' template. Rather than rewrite or render anything from a category page you can handle all the output within your 'news' template. Here is an example from a recent project: $limit = 5; $news_selector = "template=news_item, post_date<=today, limit=$limit, sort=sort"; $categories = $pages(1139)->children(); $segment_1 = $sanitizer->pageName($input->urlSegment1, true); // URL segments are already sanitized as page names but not to lowercase if($segment_1) { $current_category = $categories->get("name=$segment_1"); if($current_category) { // the segment is a valid news category $news_selector .= ", news_category=$current_category"; $page_title = "$current_category->title news"; } else { // the segment is invalid so throw 404 throw new Wire404Exception(); } } $news_items = $pages->find($news_selector); $total_pages = ceil($news_items->getTotal() / $limit); The effect of this is that if there is a valid URL segment then only news items from that category are listed, but if there is no URL segment then all news items are listed.
-
@ethfun, thanks for the module I suggest you prefix the classes coming from the parent pages with "parents-" (or better "parent-" for the direct parent and "parents-" for grandparents). This is because a page name may start with a digit but CSS selectors don't like that. That is from the CSS2 spec - I can't lay my hands on the CSS3 equivalent right now but I believe it is still advisable to avoid classes starting with digits.
-
Anyone successfully added CKEditor shortcut keys?
Robin S replied to Robin S's topic in General Support
Hi @stufru, welcome to the forums. The file is still downloadable, but maybe there is some forum restriction that prevents users with no posts from downloading (?). Now that you have made a post perhaps it works? If not the entire plugin code is in the post above - just copy it into a file named "plugin.js" and put that inside a folder named "keystrokes". Then copy that folder to /site/modules/InputfieldCKEditor/plugins and activate the plugin from your CKEditor field settings under "Extra Plugins". -
Just adding to what abdus and Macrura have said: you use URL segments to do this, but you don't need to hook page paths or render any different page. Your category pages can use a template with only a title field and with no corresponding template file - these category pages only exist for the purpose of being selected in a Page Reference field in your news article pages. In your 'news' template (the template of the parent page of the news articles) you check for a URL segment and if there is one you use that in a selector to match only news articles that have that category selected. You can do a kind of sanitizing of the URL segment by first checking if there is any page by that name using your category template or under your category parent - if there isn't then you throw a 404.
-
I think I get it now - you are talking about a "Fieldset in Tab" fieldtype, right? An InputfieldWrapper is something different. Thanks for the report - should be fixed in v0.0.3.
-
Unfortunately there's no good solution to this that I can see while still using ProcessPageEditLink (i.e. the link modal window). That's because ProcessPageEditLink applies $sanitizer->url to existing link hrefs and the options for it are not configurable within the module. And even if the options were configurable it turns out that it's impossible for javascript links to pass this sanitizer because PHP's FILTER_VALIDATE_URL is always applied. The workings of ProcessPageEditLink seem a bit inconsistent to me so I have opened a GitHub issue. A workaround you could use is to create a Hanna code for inserting javascript links, with attributes for 'href' and 'text'. If you install Hanna Code Dialog you can get a dialog UI in CKEditor.
-
One more option: when debug mode is true you can hover the inputfield open/close toggle to see the field name.
- 14 replies
-
- 1
-
-
- field name
- field label
-
(and 1 more)
Tagged with:
-
@Pretobrazza, I just tested CSV import of FieldtypeLeafletMapMarker fields with the ImportPagesCSV module and it works fine but needs a couple of simple modifications to the ImportPagesCSV module. Add FieldtypeLeafletMapMarker to the array of allowed fieldtypes: /** * List of Fieldtypes that we support importing to * */ protected $fieldtypes = array( 'FieldtypePageTitle', 'FieldtypeText', 'FieldtypeTextarea', 'FieldtypeInteger', 'FieldtypeFloat', 'FieldtypeEmail', 'FieldtypeURL', 'FieldtypeCheckbox', 'FieldtypeFile', 'FieldtypePage', 'FieldtypeLeafletMapMarker', ); Tell the module how to handle the import of the FieldtypeLeafletMapMarker fieldtype: /** * Assign a value to a page field * */ protected function importPageValue(Page $page, $name, $value) { $field = $this->fields->get($name); if($field->type instanceof FieldtypeFile) { $value = trim($value); // split delimeted data to an array $value = preg_split('/[\r\n\t|]+/', $value); if($field->maxFiles == 1) $value = array_shift($value); $data = $page->ImportPagesCSVData; $data[$name] = $value; $page->ImportPagesCSVData = $data; } elseif($field->type instanceof FieldtypeLeafletMapMarker) { $value = trim($value); // If importing pipe-separated latitude and longitude values, e.g. "-46.0026999|168.03567" // list($lat,$lng) = explode('|', $value); // $page->$name->lat = $lat; // $page->$name->lng = $lng; // If importing address string (automatically geocoded on import) $page->$name->address = $value; } else { $page->set($name, $value); if($name == 'title') $page->name = $this->sanitizer->pageName($value, 2); // Sanitizer::translate } } You'll see I added two ways to import the map pin location: lat/lng (commented out) or address. If you import an address string the lat and lng are geocoded automatically on import. If you import lat and lng without an address then the pin is placed at that location but no address string is automatically generated. If you were to import an address string and a lat/lng (not shown here and not recommended) then the lat/lng is ignored and the location is geocoded from the address string - i.e. the same as just importing an address string. You could add a zoom value if you wanted - just separate from the other value(s) with a pipe and adapt the example for lat/lng, i.e. explode() and list().
-
How to capture page containing a pagetable?
Robin S replied to bmacnaughton's topic in API & Templates
@bmacnaughton, give the following hook a try (must be in /site/init.php or in init method of module). Seems to work well for both PageTable additions and edits of existing items. $this->addHookBefore('InputfieldPageTableAjax::checkAjax', function($event) { $page_id = (int) $this->input->get('id'); $item_id = (int) $this->input->get('InputfieldPageTableAdd'); if($page_id) $page = $this->pages->get($page_id); // $page is the container page if($item_id) $item = $this->pages->get($item_id); // $item is the PageTable item // ... }); Edit Nov 2017: more information in this post... -
Could you explain some more about what you are doing at the time you see this error? I'm not sure what you mean by 'edit the inputfieldwrapper field'. Are you editing a field's settings in admin or via the API?
-
The role must have Edit permission for the template: page-sort and page-move are sub-permissions of the page-edit permission.
-
It looks like ProcessPageEdit does not use the addActionValue() method but builds the dropdown independently: https://github.com/processwire/processwire/blob/3fc9f69da75e1bc4a3f0842f12a57bd6a1b65099/wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module#L454-L491 Doesn't seems like it would be easy to modify that - probably via JS would be the only way. Maybe you could open a GitHub request asking to make it easier to modify that dropdown menu.
-
I think this would do the job: $cloneable = $page->parent->addable($page); // boolean true/false Plus check that the user has the page-clone permission, as @arjen suggested.
-
Thanks @abdus, that gave me the clue to getting Tracy working in modals. Just uncheck the "Hide Debug Bar in Modals" options in the Tracy config.
-
Hi @adrian, just leaving this here now while I remember for when you are back. I'm not able to use Tracy inside a ProcessPageEdit hook when the page being edited is a PageTable page (i.e. in the modal window). In /site/ready.php (or /site/init.php)... $this->addHookBefore('ProcessPageEdit::execute', function($event) { bd('testing'); });
-
I like to use the Connect Page Fields module but there is also another approach using an SQL query on the table of the Page field. An example... ...based on a suggestion from Ryan.
-
Setup > Templates > [template name] > Access tab
-
For a slider UI check out the new Jquery Ion Rangeslider module: http://modules.processwire.com/modules/jquery-ion-range-slider/ Or the earlier Range Slider module: https://modules.processwire.com/modules/range-slider/
-
PageTable input field in a module
Robin S replied to Steven Veerbeek's topic in Module/Plugin Development
Hi @Steven Veerbeek and welcome to the PW forums I'm not clear on whether you are talking about the config page for a 'normal' module or the page created by a Process module. But I don't think either of these will achieve what you're aiming for. A module config cannot use an actual fieldtype such as a PageTable or a Repeater - with the module config you are only dealing with inputfields and that's not sufficient for a working PageTable. And while you might get a bit further with a Process module you would kind of be going against the grain of how a Process module normally works. Normally the page created by a Process module uses the 'admin' template and you don't want to be adding a PageTable field to that. So you would need to create and assign a custom template. But then you also need to be opening this page in ProcessPageEdit in order to use the PageTable field and that's not typical for Process modules. So I think you probably need to work within the 'install' method of your module to: Create a new template Create a new PageTable field (along with the template for the pages used in the field) Assign the PageTable field to the fieldgroup of the template Create a new page using the template This page would then serve as a kind of config page for your module. But then again there might be another totally different solution to the issue of how to define your image sizes without using a PageTable field. If I understand right you want a way to define a variable number of image size settings for your module. The simplest way to do that would be using a textarea field that follows some predefined formatting, e.g. one line per image size setting with width and height separated by some character such as a pipe. Then your module uses explode() to parse the settings. I also wanted a repeatable format for module config settings and thought the textarea approach was a bit limiting and error prone. You might like to take a look at the system I have used for repeatable settings in several of my modules. Not saying it's best practice or anything but it gets the job done: https://github.com/Toutouwai/ConnectPageFields/blob/ef9a03d08f0e724724f13ebdb8dfb35a4662ec26/ConnectPageFields.module#L191-L340 If you come up with a better approach to repeatable module config settings be sure to share it!- 1 reply
-
- 1
-
-
- inputfield
- module
-
(and 1 more)
Tagged with:
-
-
Has anyone installed Processwire on Amazon EC2?
Robin S replied to modifiedcontent's topic in General Support
A write-up/tutorial would be much appreciated when you're ready! -
Nice site. @rick mentioned the slow loading of some images. The one on this page especially so: https://www.cds-service.com/en/solutions/remarketing/ It's 1.5MB!
-
That sounds sensible. Thanks for the fix.