-
Posts
4,928 -
Joined
-
Days Won
321
Everything posted by Robin S
-
Fair enough. Looking a bit closer at the native edit modal I see that the normal Save button is hidden and a replacement Save button is rendered as part of the modal frame. I don't see how that could work with a 2-step page creation process. And keeping the modal open for errors is something I hadn't considered - it's actually a bit of a shortcoming of the native edit modal, which closes without displaying required field warnings, etc.
-
The latest update to this module is really great. I notice that when adding a new page in the modal window the "Save" button does not close the modal like it does when using the native modal page edit feature (for AsmSelect). Could the Save button action be consistent with the native modal edit Save action, or do you think it's better to keep the modal open after save for newly added pages?
-
Intermediate template structure without string concatenation
Robin S replied to Pete Jones's topic in API & Templates
My preference is to use output buffering. Works great with IDE completion, matching, etc. <?php ob_start(); // $band1_content ?> <div class="w-container inset-container tabs filter-options"> <a class="w-inline-block pr-tabs" data-group=""><div class="pr-tabs-text">All</div></a> <a class="w-inline-block pr-tabs" data-group="<?= $pages->get(1015)->name ?>"><div class="pr-tabs-text blue"><?= $pages->get(1015)->title ?></div></a> <a class="w-inline-block pr-tabs" data-group="<?= $pages->get(1016)->name ?>"><div class="pr-tabs-text blue"><?= $pages->get(1016)->title ?></div></a> <a class="w-inline-block pr-tabs" data-group="<?= $pages->get(1017)->name ?>"><div class="pr-tabs-text blue"><?= $pages->get(1017)->title ?></div></a> </div> <?php $band1_content = ob_get_clean(); ?>- 13 replies
-
- template
- intermediate
-
(and 1 more)
Tagged with:
-
I think maybe you mean not being able to use pagination when using results not directly from a single find query. And I believe that's true - if you build a PageArray in memory like $notViewed in gebeer's example then you can't use the pagination module on it out-of-the-box. But there are solutions. Do a find query on your PageArray IDs like this: $pages->find("id=$notViewed, limit=10, sort=-created"); Or check out Soma's techniques here.
-
You don't need to do anything different with your CSS than you would do on a static website - that goes for the MSN module, any PW module and PW in general. Your CSS just sits in a file linked in the <head> of your template. If I understand correctly you had an HTML page "start.html" and in PW you have successfully added a template "start" associated with template file "start.php". Lets use a simplified example and say start.php looks like this... <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title><?= $page->title ?></title> <link rel="stylesheet" href="/site/templates/css/mystyles.css"> </head> <body> <ul> <li><a href="/page-1/">Page 1</a></li> <li><a href="/page-2/">Page 2</a></li> <li><a href="/page-3/">Page 3</a></li> </ul> <?= $page->body ?> </body> </html> ...and that unordered list is your menu. Let's also assume you have added those 3 pages to your PW website via the admin. Now you want to replace the static menu with a dynamic menu generated by MSN. You replace the menu markup with the call to MSN. No options are needed because your menu markup doesn't have any classes or anything not generated the MSN default. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title><?= $page->title ?></title> <link rel="stylesheet" href="/site/templates/css/mystyles.css"> </head> <body> <?php $nav = $modules->get("MarkupSimpleNavigation"); // load the module echo $nav->render(); // render default menu ?> <?= $page->body ?> </body> </html> But suppose your static menu does have some classes and also an item for the Home page. <ul class="main-menu"> <li class="menu-item"><a class="menu-link" href="/">Home</a></li> <li class="menu-item"><a class="menu-link" href="/page-1/">Page 1</a></li> <li class="menu-item"><a class="menu-link" href="/page-2/">Page 2</a></li> <li class="menu-item"><a class="menu-link" href="/page-3/">Page 3</a></li> </ul> Now you do need to set some options for MSN. <?php $nav = $modules->get("MarkupSimpleNavigation"); // load the module // set some options $nav_options = array( 'show_root' => true, 'outer_tpl' => '<ul class="main-menu">||</ul>', 'list_field_class' => 'menu-item', 'item_tpl' => '<a class="menu-link" href="{url}">{title}</a>' ); echo $nav->render($nav_options); // render the menu ?> Get the idea? So if you were using a bootstrap menu in your static website then you just need to use the MSN options array (and occasionally a hook if you have some more unusual markup) to tell MSN to generate the markup you want.
-
Module: AIOM+ (All In One Minify) for CSS, LESS, JS and HTML
Robin S replied to David Karich's topic in Modules/Plugins
A feature request: Sass support (specifically SCSS). Thanks! -
A couple of requests to make working with templates in Admin more streamlined: 1. Display the "Label" field in the "New Template" screen - I always like to label my templates and currently this requires you to re-open the template you have just created. Also, I'd rather have the template screen remain open after adding a template rather than be sent back to the Templates overview. These changes would make the "New Template" process more consistent with the "New Field" process. But of course the likely reason for no Label field and the closing of the template screen is because it's actually "New Templates" plural not "New Template" singular. Myself, I've never felt the need to add multiple templates at once but I expect others do. Maybe "New Template" and "New Templates" could be separate commands? 2. When duplicating a template (Add New Templates > Duplicate fields used by another template) it would be nice if field overrides (widths, descriptions, etc) were included in the new template(s). It can be quite time-consuming to set these up, and if you are duplicating fields of an existing template I think you also want to duplicate the overrides more often than not.
- 3 replies
-
- 12
-
Module Visual Page Selector (commercial page picker module for ProcessWire)
Robin S replied to kongondo's topic in Modules/Plugins
Would you mind making the README available to prospective purchasers? Likewise the README for Media Manager? -
For images in an images field, you can create any sizes you need via PW's native resizing methods. For images inside an RTE field you can use a textformatter module. The idea would be to detect images in the RTE block and replace them with your own custom srcset markup. The Image Interceptor module is a good one to look at if you want to get ideas for a custom module. But there is already the TextformatterImageSRCSET module ready to go. And also check out the ImageToPicture module.
-
Rather than define a parent for selectable pages in your page field, try the "Custom PHP code to find selectable pages" option... return $pages->find("parent=/clients/{$this->user->name}/categories/");
-
@BitPoet: Incidentally, one reason I thought a sister "Page Child Templates" module would be useful is that it avoids any potential difficulties there might be in extending the "Add New" feature (which normally requires allowed templates to be configured for both parent and child templates, although it's not clear to me why the parent template restriction on children is logically necessary for this feature). If it were possible to specify for a given page what template(s) may be used for child pages then the Page Add Bookmarks feature could be used in place of the original "Add New" feature. The Page Add Bookmarks feature just adds a page under a given parent in the tree, but if a "Page Child Templates" module has locked down allowed templates for that parent then you have a pretty foolproof substitute for "Add New" without having to add extra unnecessary templates for those parent pages. My understanding of the relationships required is pretty limited, but looking at your code for the Template Parents module it looks like it could be adapted for a Page Child Templates module. The way I imagine it working is that for any page that has allowed templates for children configured, the module stores a row in a database table containing allowed template IDs for that page ID. Then when a new page is added, the filterAllowedParents function hooked to ProcessPageAdd::getAllowedTemplates filters the list of allowed templates according to any template IDs that are stored for the new page's parent page ID. But I might be overlooking some complexity here. I'll probably have a tinker with your Template Parents module to see if I can adapt it myself but I'm a bit of an amateur.
-
Loving this module - perfect for a site I'm currently developing. Just noticed a bug: allowed parents selected from Setup > Templates > Edit Template are not saved successfully (no selection is saved). Allowed parents selected from Setup > Template Parents are saved okay. Another thought: how about a sister module for Template Parents, "Page Child Templates"? So for any page you can define allowed templates that may be used for child pages. Now I'm just being greedy
-
I'm thinking of the same "Add New" functionality you get when you use the core "Allowed template(s) for parents" + "Allowed template(s) for children" + "Show in the add-page shortcut menu" options. It lets you add a new page of a particular template in one step because PW "knows" where in the tree a page of that template is allowed to go. In theory this functionality could also apply to templates with a parent page restriction defined with your module, but I'm not sure how difficult it would be to extend the Add New functions to allow for this.
-
Thanks for the replies. @elabx: Yeah, I'm already doing a similar workaround using the ->not method. $page_array_1 = $pages->find(selector_1); // do some stuff with $page_array_1 $page_array_2 = $pages->find(selector_2); // do some stuff with $page_array_2 // then to subtract $page_array_1 from $page_array_2... $page_array_2->not(selector_1); But it seems wrong to have to use the same selector again when you already have the PageArray you want to remove. I figured there has to be a better way... ...and there is, but it's not in the docs or cheatsheet. Thanks BitPoet.
-
There is a remove method for WireArray/PageArray that removes a single given item from the array. But how about removing all the items in one PageArray from another? So basically like PHP's array_diff for PageArray - any suggestions for this?
-
BitPoet, many thanks for this module! When attempting to go to the settings page for Template Parents Process in PW v2.7.2 I get an error: "Undefined index: inheritSettings in ...\site\modules\TemplateParent\ProcessTemplateParents.module on line 232" Also, do you think there's a way to have templates that have been given a parent page restriction with this module appear in the "Add New" menus?
-
Superb!
-
Often I want to limit the placement of pages with a particular template to a particular parent page in the tree. Many times this parent page doesn't need to have it's own unique template, but I end up duplicating one of my existing templates (lets say it is "basic-page") just to make sure editors don't have the ability to mess up the placement of pages, and so I can make make use of the "Add New" shortcut. So I end up with "basic-page" and duplicates "basic-page-2", "basic-page-3", etc (naming is just for argument's sake). When templates are duplicated the problem isn't so much the template files, because it's easy to manually assign the file of basic-page to basic-page-2 and basic-page-3. The problem is maintenance - if I want to add a field to basic-page, change a label or field width override, etc, I now have to repeat these changes on multiple templates. It becomes difficult to keep the duplicated templates in sync. Having a template setting "Allowed page id(s) for parent" would avoid the need to duplicate templates in this situation. An alternative possibility is some system of template inheritance, but that's another kettle of fish.
-
Anyone successfully added CKEditor shortcut keys?
Robin S replied to Robin S's topic in General Support
Got it sorted, and complete plugin code is: // Keyboard shortcuts for headings 1-6, p ( function() { CKEDITOR.plugins.add( 'keystrokes', { init: function( editor ) { editor.addCommand( 'h1', { exec: function( editor ) { var format = { element: 'h1' }; var style = new CKEDITOR.style(format); style.apply(editor.document); } } ); editor.addCommand( 'h2', { exec: function( editor ) { var format = { element: 'h2' }; var style = new CKEDITOR.style(format); style.apply(editor.document); } } ); editor.addCommand( 'h3', { exec: function( editor ) { var format = { element: 'h3' }; var style = new CKEDITOR.style(format); style.apply(editor.document); } } ); editor.addCommand( 'h4', { exec: function( editor ) { var format = { element: 'h4' }; var style = new CKEDITOR.style(format); style.apply(editor.document); } } ); editor.addCommand( 'h5', { exec: function( editor ) { var format = { element: 'h5' }; var style = new CKEDITOR.style(format); style.apply(editor.document); } } ); editor.addCommand( 'h6', { exec: function( editor ) { var format = { element: 'h6' }; var style = new CKEDITOR.style(format); style.apply(editor.document); } } ); editor.addCommand( 'p', { exec: function( editor ) { var format = { element: 'p' }; var style = new CKEDITOR.style(format); style.apply(editor.document); } } ); editor.setKeystroke( CKEDITOR.ALT + 49 , 'h1' ); // ALT + 1 editor.setKeystroke( CKEDITOR.ALT + 50 , 'h2' ); // ALT + 2 editor.setKeystroke( CKEDITOR.ALT + 51 , 'h3' ); // ALT + 3 editor.setKeystroke( CKEDITOR.ALT + 52 , 'h4' ); // ALT + 4 editor.setKeystroke( CKEDITOR.ALT + 53 , 'h5' ); // ALT + 5 editor.setKeystroke( CKEDITOR.ALT + 54 , 'h6' ); // ALT + 6 editor.setKeystroke( CKEDITOR.ALT + 55 , 'p' ); // ALT + 7 } }); } )(); After adding the plugin it needs to be activated in the field settings > Input > Extra Plugins keystrokes.zip -
Anyone successfully added CKEditor shortcut keys?
Robin S replied to Robin S's topic in General Support
Thanks! That plugin code works perfectly for all the basic commands. Unfortunately I'm having trouble finding the names of commands for items in the Format dropdown (headings 1-6, paragraph, etc). That's really a CKEditor problem rather than a PW problem. Will post the solution here if I can find one. -
Anyone successfully added CKEditor shortcut keys?
Robin S replied to Robin S's topic in General Support
The code above is from the docs for CKEditor v3, so that's not applicable. The v4 docs give the following example... editor.setKeystroke( CKEDITOR.CTRL + 115, 'save' ); // Assigned Ctrl+S to the "save" command. editor.setKeystroke( CKEDITOR.CTRL + 115, false ); // Disabled Ctrl+S keystroke assignment. editor.setKeystroke( [ [ CKEDITOR.ALT + 122, false ], [ CKEDITOR.CTRL + 121, 'link' ], [ CKEDITOR.SHIFT + 120, 'bold' ] ] ); ...but I'm still not sure where this should be added to be applied in PW's CKEditor module. -
CKEditor doesn't provide shortcut keys for applying headings 1-6 and this makes text formatting slower than it needs to be. I'd like to add shortcuts for headings but I'm not sure where the config code should go. The CKEditor docs for shortcut keys give the following example: Edit: wrong version, see next post // This is actually the default value. config.keystrokes = [ [ CKEDITOR.ALT + 121 /*F10*/, 'toolbarFocus' ], [ CKEDITOR.ALT + 122 /*F11*/, 'elementsPathFocus' ], [ CKEDITOR.SHIFT + 121 /*F10*/, 'contextMenu' ], [ CKEDITOR.CTRL + 90 /*Z*/, 'undo' ], [ CKEDITOR.CTRL + 89 /*Y*/, 'redo' ], [ CKEDITOR.CTRL + CKEDITOR.SHIFT + 90 /*Z*/, 'redo' ], [ CKEDITOR.CTRL + 76 /*L*/, 'link' ], [ CKEDITOR.CTRL + 66 /*B*/, 'bold' ], [ CKEDITOR.CTRL + 73 /*I*/, 'italic' ], [ CKEDITOR.CTRL + 85 /*U*/, 'underline' ], [ CKEDITOR.ALT + 109 /*-*/, 'toolbarCollapse' ] ]; And the advice is that the code belongs in "plugins/keystrokes/plugin.js", but I suspect that isn't correct for PW because this file doesn't exist in the CKEditor module yet the normal keyboard shortcuts are available in PW. Which makes me think the keyboard shortcuts are defined somewhere else. The other place I thought of adding the config code is in the Custom Config Options textarea in the field settings, but the example code looks like it doesn't conform to property: value format for this field.
-
Prevent pages used as partials from being viewed directly
Robin S replied to Robin S's topic in General Support
Thanks for the ideas. @mr-fan: I think this might be the sort of thing you're hinting at - at the top of the widget templates... <?php if( empty($options['pageStack']) ) throw new Wire404Exception(); ?> Good info in this post from Jonathan Lahijani here and some info on pageStack from Ryan here. I like this solution. @LostKobrakai: Sounds like this would work, but it seems to me there are downsides to using wireRenderFile() over $page->render(). I have a lot of different widget templates and widgets are selected by editors via a page field, so using $page->render() keeps the rendering code really simple and maintenance-free. foreach($page->widgets as $widget) { echo $widget->render(); } But if I use wireRenderFile() I need a whole chain of logic to check the template of each widget and render it with the correct file for that type of widget. Besides avoiding partial pages being directly viewable, are there other benefits of wireRenderFile() that make it preferable to $page->render()? -
I have some pages that are used only as partials, to be rendered as part of other pages using $page->render() I have them inside a /widgets/ branch in my page tree. The problem is that they are viewable from the front-end: if someone visits mydomain.com/widgets/my-widget/ they see the partial HTML. Is there a way I can keep my widgets accessible to editors in the back-end and capable of being rendered in other pages but without them being directly viewable?
-
You are right of course, don't know what I was thinking there... So I think we can safely say that of the two, ->has() definitely performs better