-
Posts
5,008 -
Joined
-
Days Won
333
Everything posted by Robin S
-
Well, you should be a bit wary in that a person with edit access to the page could insert some malicious Javascript. If the person editing the website is the site owner then of course they would have no reason to do such a thing. As a general principle I think you should only make editable the parts of the code that it is essential to keep editable. For example, if your client only needs to change the "data-widget-id" attribute then make a text field just for that part and keep the rest of the snippet static in your template file. As an added benefit it also minimises the chances that they accidentally mess up the snippet code.
-
Thanks! Hope you feel better soon. I tried a few things but I don't have a good grasp of how the recommended way to set inline mode... session.setMode({path:"ace/mode/php", inline:true}) ...relates to the module's implementation of Ace. The only thing I could find relating to the PHP inline mode is in mode-php.js: ... "ace/mode/php-inline" ... So maybe this is an alternative way to set PHP inline mode? Hard to make sense of it with the source being minified.
-
Spotted a couple of things here. I think you want the last breadcrumb item outside of the foreach loop - otherwise when there are multiple parents you will get multiple copies of the 'active' item. And folks argue over what is the semantically correct markup for breadcrumbs, but when using an ordered list I think the "You are here" text should be outside the list as it doesn't represent a page in the site hierarchy.
-
By default ACE requires an opening PHP tag for syntax highlighting to work, even when set to PHP mode. But there is an 'inline' mode that enables highlighting without needing the opening tag: https://github.com/ajaxorg/ace/issues/2542 Is it possible to set this inline mode via the API for Inputfield ACE Extended?
-
Just an ordinary textarea - make sure the Inputfield Type is set to "Textarea" and not "CKEditor. Don't add any textformatters to the field.
-
selector Selector with multiple words to reduce results
Robin S replied to godmok's topic in API & Templates
You might be interested in this recent thread about rendering page content to an 'index' field with a save hook. I only tested it briefly but with this approach you are in control of what is saved to the index - so for Page fields for example you can save the title or any other subfield you want. -
@MaryMatlow , if the widget always occurs in the same place in your template (i.e. the editor doesn't need to move it around) then you could have a dedicated textarea field in your template for the code snippet.
-
In some modules I am conditionally loading JS to the module config page like this: if($this->input->get->name == $this->className) { // load script }
-
I think this should work... <a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#accordion-1" href="#accordion-1-<?php echo $presalefaq->id; ?>"><?php echo $presalefaq->title;?></a> ... <div id="accordion-1-<?php echo $presalefaq->id; ?>" class="panel-collapse collapse"> ...but your solution is fine also.
-
selector Selector with multiple words to reduce results
Robin S replied to godmok's topic in API & Templates
@godmok, what is the maximum number of words you can put into this search query before you hit the MySQL limit? I would have thought that would be a lot of words; more than any person would type into a search input. I have a site that explodes and loops over all search terms using the %= LIKE operator, searching within 12 fields. I can throw whole paragraphs of text into the search input without coming up against any MySQL limit. -
Create a Module: image upload to another page and autocomplete
Robin S replied to Qualtext's topic in General Support
@Macrura, I also haven't looked in detail at Qualtext's module, and there are some similarities to both Selectize and Media Manager. But at a glance I can see some differences from Selectize: Image upload > page creation is included in the module. Uploaded images are pixel-compared for uniqueness to avoid duplicates. The ajax-loading features that come with extending InputfieldPageAutocomplete would be useful if you have thousands of image pages. Ajax-loading is possible with the jQuery Selectize plugin but not offered out-of-the-box in your PW module (please correct me if I'm wrong there). So a very worthy contribution to the PW module ecosystem I think.- 7 replies
-
- 1
-
-
- image
- autocomplete
-
(and 2 more)
Tagged with:
-
Create a Module: image upload to another page and autocomplete
Robin S replied to Qualtext's topic in General Support
Hi @Qualtext, Nice job on the modules! Most of us around here are not true pros, and I don't think you need a pro to finish off your modules - you're doing great so far and you're nearly done. Just stick at it. You've probably seen it already, but this is the docs page that is particularly useful for module development: https://processwire.com/api/ref/module/ The bits I quote below are from this page. It isn't necessary to merge everything into a single module file. It's not unusual for a single module release to actually contain two or more modules. Put both modules inside the same directory, decide which is the primary module and have that module install the other automatically by using the "installs" property in the getModuleInfo() array. This takes care of item 1 or 2 in your list of installation steps. Another thing you could do to finish off your modules for release is add code that creates some of the required pages and templates. You can use the ___install() method to do this. In your list of installation steps I think your install method could potentially take care of the following items: 3,4,5,6,7,9. Items 8 and 10 you leave up the user. Search the forum and API docs and look at the code of other modules to understand how to create templates, fields and pages via the API. Give your auto-created templates/fields/pages names that are unlikely to be already in use, e.g. prefix them with the name of your module class. The labels/titles can be anything though. Here are some links to start with:- 7 replies
-
- 2
-
-
- image
- autocomplete
-
(and 2 more)
Tagged with:
-
I can't reproduce this. I can edit a textarea on the frontend and no HTML markup creeps in anywhere. Markdown works as expected when the Markdown textformatter is applied to the field. Do you have any other textformatters applied to your textarea? Any browser extensions that might be interfering?
-
You could group some config fields inside a fieldset and set it to collapsed. $fieldset = $this->modules->get("InputfieldFieldset"); $fieldset->collapsed = Inputfield::collapsedYes; // add some fields to $fieldset
-
If you enter PHP code into an inputfield in Page Edit you would have to eval() it in your template in order for it to execute. But the idea of entering PHP code into Page Edit is really not good. If you want to execute a PHP block within some HTML coming from Page Edit then use the Hanna Code module.
-
Limit field to a specific page or branch of tree
Robin S replied to adrian's topic in Getting Started
Ahh, good idea! -
Limit field to a specific page or branch of tree
Robin S replied to adrian's topic in Getting Started
Hi Adrian, My Custom Inputfield Dependencies module is released and the forum thread is here. Not a very precise module name - I struggled with it. You'll see that the effect of my module is similar to what you propose above, but using what is available in the core (and Hanna Code) now. But I think it would be cool to have new features added to the core to allow this directly in field settings like you propose, so if you want to make a Github request I'll gladly add my +1. Hopefully you can use Custom Inputfield Dependencies for what you had in mind in this thread's original post. -
Custom Inputfield Dependencies A module for ProcessWire CMS/CMF. Extends inputfield dependencies so that inputfield visibility or required status may be determined at runtime by selector or custom PHP code. Overview Custom Inputfield Dependencies adds several new settings options to the "Input" tab of "Edit Field". These are described below. Note that the visibility or required status of fields determined by the module is calculated once at the time Page Edit loads. If your dependency settings refer to fields in the page being edited then changes will not be recalculated until the page is saved and Page Edit reloaded. Usage Install the Custom Inputfield Dependencies module. Optional: for nice code highlighting of custom PHP install InputfieldAceExtended v1.2.0 or newer (currently available on the 'dev' branch of the GitHub repo). The custom inputfield dependencies are set on the "Input" tab of "Edit Field". Visibility Show only if page is matched by custom find Use InputfieldSelector to create a $pages->find() query. If the edited page is matched by the selector then the field is shown. Show only if page is matched by selector As above, but the selector string may be entered manually. Show only if custom PHP returns true Enter custom PHP/API code – if the statement returns boolean true then the field is shown. $page and $pages are available as local variables – other API variables may be accessed with $this, e.g. $this->config In most cases $page refers to the page being edited, but note that if the field is inside a repeater then $page will be the repeater page. As there could conceivably be cases where you want to use the repeater page in your custom PHP the module does not forcibly set $page to be the edited page. Instead, a helper function getEditedPage($page) is available if you want to get the edited page regardless of if the field in inside a repeater or not. $edited_page = $this->getEditedPage($page); Required The settings inputfields are the same as for Visibility above, but are used to determine if the field has 'required' status on the page being edited. https://github.com/Toutouwai/CustomInputfieldDependencies http://modules.processwire.com/modules/custom-inputfield-dependencies/
- 65 replies
-
- 21
-
-
-
Redirect to Lister after Save + Exit via Hook
Robin S replied to gebeer's topic in Module/Plugin Development
The problem with redirecting back to the Lister is that you will lose your current page in the pagination and any filters that were applied, which IMO would be pretty annoying. The nice thing about the modal editing is that everything is just as you left it after you save. -
Redirect to Lister after Save + Exit via Hook
Robin S replied to gebeer's topic in Module/Plugin Development
Lister Pro has an option to edit links in a modal window. If you don't have Lister Pro I think it would be possible to turn the edit links of the core lister into modal links with a hook or JS. Edit: for non-Pro lister you can make edit links modal using Admin Custom Files. Enable for process "ProcessPageLister" and add file "ProcessPageLister.js"... $(document).ajaxComplete(function(){ var $a = $('.PageListerActions .PageEdit').not('.PageAdd'); $a.addClass('pw-modal pw-modal-large'); $a.attr('data-buttons', '#ProcessPageEdit > .Inputfields > .InputfieldSubmit .ui-button'); }); -
Check out Profields Table, Repeater or Profields Repeater Matrix, PageTable (can't find a good link for this but it's an installable core module).
-
Limit field to a specific page or branch of tree
Robin S replied to adrian's topic in Getting Started
Hi Adrian, I have a module that could be helpful here - just putting the finishing touches on it and will release this weekend. Cheers, Robin. -
A repeater will work, but it's sort of overkill for repeating just a single line of text. Behind the scenes it is creating a page for every line. This is probably the way to go. If you wanted your own custom markup you could explode and foreach a textarea. $lines = explode("\n", $page->my_textarea); if(count($lines)) { echo "<ul class='my-special-list'>"; foreach($lines as $line) { echo "<li class='my-list-item'>$line</li>"; } echo "</ul>"; } For sure, and for more complex repeatable items see the Table fieldtype.
-
Mimic a Microsoft Access application with Processwire
Robin S replied to Krlos's topic in Getting Started
I assume that when you say parent and child you are talking about pages. If you need to edit the fields of the child pages directly in the listing then you could use Lister Pro for viewing the children list and editing the fields using the inline AJAX editing feature: https://processwire.com/blog/posts/inline-ajax-page-editing-comes-to-listerpro-processwire-2.6.6/ If you just need to show the fields from the child pages then you could generate a table from the child pages using Matrix or RuntimeMarkup. -
Not to put you off making your module, but I believe RuntimeMarkup can do this.