-
Posts
5,039 -
Joined
-
Days Won
340
Everything posted by Robin S
-
Hi @adrian, Not a major, but the Console panel layout is a bit messed up when the panel is opened as a window.
-
We are getting off-topic here, but... If @mindplay.dk is not actively maintaining the module then I think it would be good to update it. It would be cool to have as an option in Tracy, or the module could be forked. I found that the module isn't working in PW3 where a namespace is declared at the top of template files. I had to modify the module code to add the namespace to stubs.php because the FileCompiler does not compile this file. Also, I'm probably overlooking something but I can't see why the module needs to rebuild the stubs file after every Session::redirect and every ProcessPageView::finished. I think that comment is due to a misunderstanding of what the module is for. The module only adds code completion to $page for field names in the current template - it isn't intended to provide code completion for all API variables (for that you have to add a DocBlock in every template file with tags for each API variable).
-
@Vigilante, please use code blocks for your code examples. If you really need to do it this way then you could do... <?php foreach($parents as $parent): ?> <?php $children = $parent->children("id=$everything"); // PageArray dereferenced as string of pipe-separated IDs ?> <?php if(count($children)): ?> <section> <h2><?= $parent->title ?></h2> <ul> <?php foreach($children as $child): ?> <li><?= $child->title ?></li> <?php endforeach; ?> </ul> </section> <?php endif; ?> <?php endforeach; ?> ...but it's not very efficient. Instead, I suggest you don't need the $parents PageArray and should just work on sorting the $everything PageArray. For example: // Sort by parent in the selector for $everything $everything = $pages->find("template=basic-page, sort=parent"); // Initialise $parent_title $parent_title = ''; foreach($everything as $one) { // By default, this is not a new section $new_section = false; if($one->parent->title !== $parent_title) { // If the parent title of $one is different to the existing $parent_title // then this is a new section $new_section = true; // Set $parent_title $parent_title = $one->parent->title; } // If this is a new section and $one is not the first item in $everything // close ul and section from previous section if($new_section && $one !== $everything->first) echo "</ul></section>"; // If this is a new section, add the open section, heading and open ul if($new_section) echo "<section><h2>$parent_title</h2><ul>"; // Output the li echo "<li>$one->title</li>"; // If $one is the last item in $everything then close the ul and section if($one === $everything->last) echo "</ul></section>"; } If you need some custom sort of the parents then you could loop through $everything and add a custom sort property to each item, then sort $everything by the custom property. Not exactly the same, but this post shows the general idea:
-
I'm wondering about this part... If these options (checkboxes) are added dynamically, are all the options also defined in the selectable options for the Select Options field? You cannot save an option to a Select Options field if it is not one of the pre-configured selectable options. If you want to dynamically add to the selectable options then this reply has some example code:
- 3 replies
-
- 1
-
-
- checkboxes
- selectableoptionarray
-
(and 1 more)
Tagged with:
-
Front-end custom form: how to retrieve an inputfield css class
Robin S replied to Federico's topic in General Support
When you can find a setting in admin and you want to know what the property name will be in API, a handy trick is to hover the collapse toggle of the setting. When $config->debug = true you will see the name of the input appear, and 99% (all?) of the time that will be the property name in the API. And Tracy will give you the whole shebang: -
Front-end custom form: how to retrieve an inputfield css class
Robin S replied to Federico's topic in General Support
@Federico, I'm not sure I completely understand your question, but if you want to know what inputfield type is used for a Page Reference field you can get that from the "inputfield" property. The type setting in admin: Getting the type via InputfieldPage using the API: // $inputfield is InputfieldPage object $inputfield = $pages(1234)->getInputfield('YOUR_PAGE_REFERENCE_FIELD'); // $type is 'InputfieldSelect' $type = $inputfield->inputfield; P.S. Are you using Tracy Debugger? Things are a lot easier once you start using this module. You can dump an object (e.g. an inputfield) and explore all its properties. -
Hi @tpr, AOS has a stylesheet rule... html.noFilenameTruncate i.fa-file-image-o, html.noFilenameTruncate .InputfieldFileInfo i { left: -21px !important; top: 3px; float: left; } ...but this is too broad and affects the FontAwesome icon 'file-image-o' outside of the image inputfield when the noFilenameTruncate option is active (e.g. in the icon picker or in the module listing if that icon is used for a module).
-
Well, you could say that PW has a gap when it comes to front-end anything. I don't know if there's a good authoritative document explaining this anywhere, but I think it's fair to say that part of the PW philosophy is that the core does not get involved with the front-end of your site. Depending on how experienced you are with front-end development this is either something that makes your job easier or more difficult. So you have all the freedom (likewise, responsibility) to do whatever you want with your front-end and PW will never mess it all up for you (likewise, help build your front-end for you).
-
You can nest as many regions as you want, so long as they are all defined in _main.php. In other words, the only limitation is that you can't define new regions in a template file that is then included in another template file. So despite the first blog post on Markup Regions saying... ...Ryan later decided to remove this feature. If you are concerned about performance remember to use markup region hints to make the regions parsing more efficient.
-
Disable frontend-editing if other format then HTML?
Robin S replied to dragan's topic in API & Templates
Are you using Option A? If so, switch to Option B, C or D and then you'll only get editable fields where you ask for them in your template file. -
That's a great tip, will do that myself in future. So often an otherwise nice typeface has a weird unrecognisable ampersand or something. Cases in point... http://www.myfonts.com/fonts/font-fabric/nexa/regular/glyphs/716952/445 http://www.myfonts.com/fonts/intelligent-foundry/averta/regular/glyphs/756381/1184
-
Admin users: when migrating a live site to a new host, and you don't want users making changes to DB content during the migration. Front-end users: temporarily suspending member-only privileges for a user (e.g. because of some infraction).
-
This is a question about using the system notices: $this->message(), $this->warning(), $this->error(). If I have a method that is is called by an AJAX request, I can't trigger a system notice immediately (would be great if this was possible). But is there some way to "queue" the notice so that it appears on the next admin page load? P.S. I know about the System Notifications module, but it's of no use if you need AJAX notices for a publicly shared module as there is no guarantee that the user will have System Notifications installed. Edit: found it... $session->message() $session->warning() $session->error()
-
- 2
-
-
That did the trick. Another little thing I noticed is your font stack: font-family: "Hind Madurai", "woodford_bourne", sans-serif; You are specifying "Hind Madurai" from Google Fonts as the first preference, but this is not actually rendered anywhere (that I could see) and instead all the text renders in the first fallback "woodford_bourne" which you are self-hosting. So maybe "woodford_bourne" is actually the typeface you actually intend to use and specifying/loading "Hind Madurai" is unnecessary?
-
I agree it would be handy, but that would be a completely different thing to what this module is doing. This module is essentially just using Pageimages::add() on the submitted URLs, and that method has no support for clipboard data. I don't think I want to disappear into the browser clipboard rabbit-hole with this module. I'll have a think about it. It would make the module significantly more complex and I'm not sure how much time I want to put into it. Maybe if I get bored sometime...
-
Very nice! One issue I noticed is that if you scroll down one increment of the mousewheel, as well as triggering the animated scroll past the hero section the text below is also scrolled, meaning the first couple of lines are already obscured behind the header. How many text lines are scrolled perhaps depends on the OS mouse settings. Maybe you could somehow capture the first mouse scroll interaction so that it only triggers the hero scroll and not scroll the rest of the page content?
-
I would do the validation a little differently, to avoid loading any more pages than you need to: // if there is a URL segment 1 if($segment1) { // get catType page $catType = $pages->findOne("parent=/type/, name=$segment1"); // if catType page exists if($catType->id) { // add this to the selector $selector .= ", catType=$catType"; } else { // invalid URL segment 1 throw new Wire404Exception(); } } Not sure in what way you were considering using has(), but that method is for checking against a PageArray/WireArray that is already loaded to memory - better to load just the page (category) you want than to load many just to filter it down again.
-
Could you give some more info about the OS and device where the problem occurs? I tested in iOS and Android and could select, copy and paste okay (a bit awkward as expected, but doable). Technique was the same on both platforms: double-tap on some text in the CKEditor window to start the selection, then drag the selection handles around the content you want to select.
-
$pageimage->maxSize() not working as described?
Robin S replied to Robin S's topic in API & Templates
I opened a new GitHub issue for this: https://github.com/processwire/processwire-issues/issues/454 -
Hi @tpr, AOS seems to be suppressing the "required" icon in the template editor. Without AOS: With AOS:
-
Cool, thanks for this! A couple of little issues I noticed after a quick try-out: 1. You have undefined variables $buttontext and $href in addAjaxSaveButton(). 2. It would be good to set a default value for the button text, both in the module config inputfield and in a construct() method, in case a user does not save the module config after installation or a user saves the config inputfield in an empty state. Other thoughts: 1. I see the module submits the form to a separate Process module. Seems like it should be possible to instead do an AJAX submission to the "action" url of the form in ProcessPageEdit, but maybe there is a good reason not to do it this way. 2. It would be cool if the module could handle/show errors in the submission - e.g. empty required fields or other inputfield errors.
-
You can turn Repeater into a kind of poor man's Repeater Matrix by adding all the fields you need to the Repeater, then adding a Page Reference field at the top to select the type of item. Use inputfield dependencies to show/hide inputfields according to what type is selected.
-
Using repeater fields - when to use & when not?
Robin S replied to Vineet Sawant's topic in Getting Started
Repeaters can scale up much better in recent versions of PW, so long as you set your repeater items to collapsed by default and use the AJAX-loading option. I suggest creating a page structure where you have a dedicated parent and template for each of Movies, Television and Theatre and all of the items for each category go under these parents. Movies Apocalypse Now Magnolia ... Television Six Feet Under Twin Peaks ... Theatre Waiting for Godot Uncle Vanya ... Then you create a Page Reference field "Roles" using the Page Autocomplete inputfield and add it to your actor template. You can easily divide the roles by category when you output the roles in your template file. You might like to try the Connect Page Fields module too - I even used the example of actors in the readme. For the awards field, I think I would stick to a repeater. Each repeater could consist of just a text field for entering the award name, or if there are certain awards that are given out each year you could use a Page Reference field to select the award and an integer field to enter the year. -
Best not to give users access to fields that they are not trusted to manage. So if only certain roles should be allowed to edit a field (for a files field editing means adding or deleting files) then set up access permissions for that field. I'm not sure it makes sense to allow users to upload files to a field but not delete them. Otherwise how do they correct their own mistakes if they accidentally upload a file to the wrong field or on the wrong page? But if you're sure you want to do this you could use the following hook in /site/ready.php: $wire->addHookBefore('Pagefiles::delete', function(HookEvent $event) { // The item about to be deleted $item = $event->arguments(0); // Only for ProcessPageEdit if($this->process != 'ProcessPageEdit') return; $page = $this->process->getPage(); $field = $item->pagefiles->field; // Now optionally use $page and $field to limit the below to particular pages, templates, fields if($this->user->hasRole('YOUR_ROLE')) { // Prevent the normal delete() method $event->replace = true; // Show the user an error message $this->error('Sorry, you are not allowed to delete files.'); } }); I don't recommend it because it will be slow and potentially result in a lot of sent mail, but the following example is a proof-of-concept for sending an email notification of deleted files. $wire->addHookBefore('Pagefiles::delete', function(HookEvent $event) { // The item about to be deleted $item = $event->arguments(0); // Only for ProcessPageEdit if($this->process != 'ProcessPageEdit') return; $page = $this->process->getPage(); $field = $item->pagefiles->field; // Now optionally use $page and $field to limit the below to particular pages, templates, fields if($this->user->hasRole('YOUR_ROLE')) { // Send email notification $m = $this->mail->new(); $m->to('someone@domain.com') ->from('someone@domain.com') ->subject('File deleted') ->body("File '{$item->basename}' was deleted by '{$this->user->name}' from field '{$field->name}' on page {$page->httpUrl}.") ->send(); } });