-
Posts
5,008 -
Joined
-
Days Won
333
Everything posted by Robin S
-
A client hired a security consultant to do a site analysis and they advised that the X-Content-Type-Options HTTP header should be set to "nosniff". The MDN docs for this header say: "Site security testers usually expect this header to be set." https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options This was easily resolved by adding the following to .htaccess Header set X-Content-Type-Options "nosniff" Do you think it would be good to add this to the default PW .htaccess file?
- 1 reply
-
- 4
-
-
Image management in custom module
Robin S replied to SoccerGuy3's topic in Module/Plugin Development
Why not use pages and proper Fieldtype fields to store the data? Seems like it would be much easier, and anything out-of-the-ordinary that you want to show within your Process module you could show within Page Edit by hooking the render of a markup inputfield, or by using one of the runtime field modules from kongondo, bernhard, kixe, or me. -
How to pass all API variables to $files->render() ?
Robin S replied to bernhard's topic in General Support
From the $files->render() docs: -
$pages->find() get by id and maintain order
Robin S replied to Torsten Baldes's topic in API & Templates
There is some code and some links to explore in this post: -
Try: $wire->addHookAfter('Field::getInputfield', function(HookEvent $event) { $page = $event->arguments(0); $inputfield = $event->return; // Only for non-superusers if($event->wire('user')->isSuperuser()) return; // Only for a particular Repeater page ID if($page->id !== 1553) return; // Set collapsed to Inputfield::collapsedNoLocked or Inputfield::collapsedHidden as suits $inputfield->collapsed = Inputfield::collapsedNoLocked; });
-
Get page with a specific template of root parent
Robin S replied to Stefanowitsch's topic in API & Templates
When you do this you load all the children of the of the root parent into memory as a PageArray, and then you get just one of those pages. It's more efficient to directly get the single page you need: $page->rootParent()->child('template=menu_submenus, include=hidden'); -
I suspect the image is corrupt in some way, or maybe contains some metadata, colour profile, etc, that can't be handled. Try opening this image in Photoshop or similar and then save it as a new JPG, making sure to use the standard sRGB colour profile.
-
When you add an image via the API rather than via the inputfield you have to do all the work yourself that the inputfield would otherwise do for you. A recent answer to a similar question, which contains a link to some code that might be useful to you:
-
v0.1.4 released. This version adds support for some new features added in Repeater Matrix v0.0.5 - you can disable the settings for matrix types (so items cannot change their matrix type), and when the limit for a type is reached it becomes unavailable for selection in the type dropdown of other matrix items. The module now requires Repeater Matrix >= v0.0.5. If you are using Repeater Matrix v0.0.4 or older then there is no need to upgrade Restrict Repeater Matrix as the new features in v0.1.4 are only applicable to Repeater Matrix v0.0.5.
-
Change how many page numbers to show between ellipses in pager
Robin S replied to thetuningspoon's topic in API & Templates
There's no special setting for the number of page links between the ellipses, but how many appear there is determined by the numPageLinks setting, which as I understand it should control how many extra page numbers appear in addition to the first and last page numbers. So you'd expect that a numPageLinks setting of 3 would achieve what you want, but it seems buggy: Why is the current page the last number and not the middle number? Why are there only two numbers here instead of three? Likewise here - why aren't there three numbers in addition to the first and last numbers? Why does the second page look like this... ...but the second to last page look like this... ? If you want to have a go at fixing it the relevant code is in PagerNav::getPager(). -
-
No, I don't think the module sets page titles. I was expecting something similar using the core "Name format for children" feature, but if you want to automatically set a title you have to use a hook. It's discussed in the topic below:
- 100 replies
-
- template
- autogenerate
-
(and 2 more)
Tagged with:
-
Hi @ryan, Thanks for the update. The section 15B update to .htaccess is nice. I'm keen to enable that on my sites as it's a good bit of extra security. But I just want to check: does this blocking only apply to files that are accessed directly by the browser and not those served by PW via $files->send()? Because on several sites I offer downloads of a set of CSV files that I build and bundle into a ZIP file on-the-fly. I create the ZIP in a WireTempDir and then send the file for download via $files->send(). So would this be affected by section 15B? I did a quick test and it seems to work okay but just want to confirm that I don't need to adjust that section of .htaccess to allow WireTempDir paths.
-
Thanks @teppo. I'm going to spend some time exploring Wireframe to see how it feels compared to my existing approach - I may yet become a convert ?. Thanks again for creating this tool and doing such a great job on the documentation website.
-
I discovered Wireframe on Sunday after exploring the GitHub repo for the ProcessWire Composer Installer project that you mentioned in the latest PW Weekly. The documentation you've written for Wireframe is just awesome ? - engaging, comprehensive and clear. I have a short question and a long question... Does it make sense to use Wireframe together with Markup Regions in any way, or would a developer choose Wireframe or Markup Regions but not both? The long question relates to what you said here: I take this to be a reference to the superiority of a MVC approach versus the "default" approach of mixing business logic and UI logic together in a PW template file. I'd like to hear more of your views on this because you didn't talk about it much in the documentation, probably because MVC and the separation of concerns is discussed in plenty of other places around the web. But I was wondering if you think a MVC approach is always the way to go, or if is something you would weigh up the pros and cons of taking into account the parameters of each specific project, e.g. the scale and complexity of the project, if a team will be working on the project, etc. Personally I use Markup Regions and don't use any separation of business logic and UI logic into different files or folders. From time to time I think about changing to an MVC approach because so many people seem to recommend it, but when I weigh it up I don't see enough advantage versus disadvantage for the kinds of projects I work on. But maybe I'm overlooking something so I'd appreciate your comments. The main benefits of MVC as I understand it are... 1. If you have a team of people working on a project, maybe with different skill sets (e.g. a front-end dev and a back-end dev), then it lets each person focus on the parts that matter to them. For example the front-end person can focus on the view file without having to see any business logic which might distract or even be unintelligible to them. This totally makes sense to me and if I worked as part of a team this by itself would make an MVC approach worthwhile. But in my case I do everything alone from start to finish - design, front-end, back-end. 2. The business logic doesn't "belong" in the same file as the markup - it's better to keep it separate and it makes it easier to update a site. This seems more contentious to me, and perhaps depends on how much business logic there is. If I have some variable that I'm using within the markup I find it very handy to have the definition/construction of that variable present alongside its usage in output. So I'm not left wondering "what was it that I put into $related_products?" and needing to navigate to some other file to find out. Now if there were heaps of business logic it might start to feel like clutter within the markup, but when I look at the template files for my projects in most cases there's actually very little business logic present. Maybe that's partly because PW is quite elegant in that you can do a lot with a few lines of code, and partly because most of my projects are not very complex. But even if I do have a lot of business logic I find that placing it at the top of the template file is no problem at all. If I need to work on it I'd rather just scroll up than open another file, and I can use my IDE to collapse any blocks of code that I don't need to focus on. Would you say that MVC is an approach that is more suited to complex projects rather than simple ones? Things like layouts and partials that are offered through Wireframe are cool, but those are also possible with Markup Regions (layout = _main.php) and built-in PW methods (partials = $files->render). I have no doubt that Wireframe is a powerful tool, but do you see it as being the right solution for all projects or just some projects?
-
@Torsten Baldes, there has been an @todo note about adding OR-group support to InputfieldSelector since 2016. Seeing as Ryan has been doing some work on InputfieldSelector recently it might be timely to open a request for this in the requests repo to bring it back to his attention. ?
-
How to I get values of a page by a field tag?
Robin S replied to Alpine418's topic in Getting Started
Try: // Get names of fields on the page that are tagged with "custom" $custom_field_names = $page->fields->find('tags=custom')->explode('name'); // Do something with the values of those fields foreach($custom_field_names as $custom_field_name) { echo $page->$custom_field_name; } -
@jonassalen, open the ProcessSetupPageName.module file in your code editor and try replacing this section at the top of the createFromFormat() method... if ($languageID == null && $this->languageSupport == true) $languageID = $this->wire('languages')->getDefault()->id; $langID = $this->wire('languages')->get($languageID)->isDefault()? null : $languageID; if ($this->languageSupport) { $userLang = $this->wire('user')->language; $this->wire('user')->language = $this->wire('languages')->get($languageID); } ...with... $langID = null; if ($this->languageSupport) { if ($languageID == null) $languageID = $this->wire('languages')->getDefault()->id; $langID = $this->wire('languages')->get($languageID)->isDefault()? null : $languageID; $userLang = $this->wire('user')->language; $this->wire('user')->language = $this->wire('languages')->get($languageID); }
- 100 replies
-
- 3
-
-
- template
- autogenerate
-
(and 2 more)
Tagged with:
-
See ProcessWire::getHttpHost(). If PW cannot match a host in your $config->httpHosts array from PHP's predefined $_SERVER variable then it gives you the first item from $config->httpHosts.
-
-
Thanks ?
-
@horst, I have implemented your request in v0.1.1 as a separate autocomplete on the "Add Module From URL" field. See the updated readme for details.
- 10 replies
-
- 3
-
-
-
- install
- class name
-
(and 3 more)
Tagged with:
-
A recent answer to a similar question:
-
selecor Using numReferences in selectors?
Robin S replied to schwarzdesign's topic in General Support
That's because ultimately the references depend on the execution of the FieldtypePage::findReferences() method. This method has to be called for each page you want to get or count the references to. And so the number of references is not a simple value in the database that you can query in a $pages->find() selector the way a field value is. Enabling selectors that query or sort by the number of references is one of the motivations behind the Connect Page Fields module. If you use this module to create a two-way relationship between Page Reference fields then it's easy to write the selector you want. Note that you can set the visibility of a Page Reference field to hidden if you don't need to see it in Page Edit but only want to query it in selectors. -
After forgetting the class name of the wonderful AdminPageFieldEditLinks module for what feels like the 100th time I decided I needed to give my failing memory a helping hand... Autocomplete Module Class Name Provides class name autocomplete suggestions for the "Add Module From Directory" and "Add Module From URL" fields at Modules > New. Requires ProcessWire >= v3.0.16. Screencast Installation Install the Autocomplete Module Class Name module. Configuration Add Module From Directory Choose the type of autocomplete suggestions list: "Module class names from directory" or "Custom list of module class names". The latter could be useful if you regularly install some modules and would prefer a shorter list of autocomplete suggestions. The list of class names in the modules directory is generated when the Autocomplete Module Class Name module is installed. It doesn't update automatically (because the retrieval of the class names is quite slow), but you can use the button underneath when you want to retrieve an updated list of class names from the directory. Add Module From URL If you want to see autocomplete suggestions for the "Add Module From URL" field then enter them in the following format: [autocomplete suggestion] > [module ZIP url] Example: RepeaterImages > https://github.com/Toutouwai/RepeaterImages/archive/master.zip Awesomplete options The "fuzzy search" option uses custom filter and item functions for Awesomplete so that the characters you type just have to exist in the autocomplete suggestion item and occur after preceding matches but do not need to be contiguous. Uncheck this option if you prefer the standard Awesomplete matching. Custom settings for Awesomplete can be entered in the "Awesomplete options" field if needed. See the Awesomplete documentation for more information. https://github.com/Toutouwai/AutocompleteModuleClassName https://modules.processwire.com/modules/autocomplete-module-class-name/
- 10 replies
-
- 23
-
-
-
-
- install
- class name
-
(and 3 more)
Tagged with: