Jump to content

Robin S

Members
  • Posts

    5,009
  • Joined

  • Days Won

    333

Everything posted by Robin S

  1. Thanks for all the great info! Lots of learning ahead of me but I love it.
  2. $tagless_images = new WireArray(); foreach ($page->images as $image) { if(empty($image->tags)) { $tagless_images->add($image); } } Now $tagless_images is a WireArray of images on the page that have no tag. Edit: this is better... $tagless_images = $page->images->filter("tags=''");
  3. Thanks for the suggestion kongondo. But I think that would effectively be the same as making my modifications to a duplicated Comments module in the site modules folder. The problem being that if I want to later upgrade to a newer version of the Comments module I would need to repeat my code modifications. Bear with me because I don't really know what I'm talking about here: I think extending the Comments module might be what I (vaguely) have in mind. If I create a module that extends the Comments module does that mean that if my module contains a renderItem() method it would overwrite the renderItem() method in the core module? And I have access to all the core Comments methods within my module?
  4. Are we talking about a situation where you have some old blog posts that you want to replicate on a new PW installation and you want to keep the old dates? And for some reason you don't want to use a custom date field to store post dates but rather rely on the page created date? If so it's just a one-time thing to set the created date of old posts so I'm not sure why it matters if the technique seems like a "hack" or not. It's not something you need to use again and again going forward. But I think using a custom date field for your post dates would be better. It gives you a lot more flexibility. Just set the field to default to today's date and then use this custom date field in any place you would otherwise use the created date.
  5. What is the best way to make changes to a core module? My current need is to modify/replace the render functions in FieldtypeComments: render(), renderList(), renderItem(), etc. I know I can iterate over comment items in my template but in this case I'd prefer to use modified functions in the module. I've already copied FieldtypeComments to my site modules folder and could make the modifications there but I'm wondering if there is a better way. I'd like to make it as easy as possible to upgrade FieldtypeComments if a new version is released. So ideally I don't want to make any changes directly in the core module files. Is there a way I can keep my modified functions in a separate file and use them in place of the core module functions? I thought this might be possible with a hook but I don't see a suitable hookable method.
  6. Thanks @adrian. I noticed that if the nominated thumbnail field is limited to one image and an image is already loaded there then the image is not replaced with the video thumbnail (but the description is updated to the video title). Is that intentional? I expected the existing image to be replaced. Although I suppose that would create a problem for someone who is wanting to load their own custom video thumbnail in place of the one grabbed from YouTube/Vimeo. Now that I've used the module a bit I've realised that in most cases I would use a different field setup to what I first tried. Initially I thought I would use an existing field on the page - in my project a user can choose a featured image or a featured video, so I thought it made sense that if a video URL was entered the featured image field contained the video thumbnail. That prompted my mention of the maxFiles issue. But now I think I want different field settings for the video thumbnail - I want to set it to non-editable because I don't want editors to try and manually override the video thumbnail or think that they need to load a thumbnail image. So I've decided that it's better to create a dedicated image field for the video thumbnail and then use field visibility settings to show/hide image fields based on if the video URL field is populated. I think I would use this kind of setup in future too so the maxFiles thing isn't an issue for me after all (sorry!). --- Edit: just noticed you already discussed some of this here and the module only replaces an existing image if the image is a video thumbnail grabbed by the module. However there does seem to be a bug. If the video URL field contains a URL and the image field contains a video thumbnail grabbed by the module (i.e. not a manually loaded image), and then the URL is changed to a different video, on page save the image field becomes empty. On a subsequent page save the image field gets the new video thumbnail.
  7. This post describes a way of overwriting the created date via the API.
  8. I'm probably missing something, but I don't see a way to filter the Comments Manager list by page (that the comment field is on).
  9. Does anyone have experience with using the Comments fieldtype for large volumes of comments? When I say large volume I'm thinking of a couple of thousand comments per page. Is the Comments fieldtype suitable for this kind of usage? Pagination would be important in this situation. I've seen solutions in the forums for pagination of comments on the front-end but what about pagination in page edit?
  10. @adrian, Thanks! So quick and the new commit works great. Actually, the title was working properly for me (video title was saved to image description field). Although not now with the new commit because I guess you have removed the code for that while you look at implementing something different.
  11. I'm trying this module for the first time but get an error when the module attempts to grab the thumbnail. Same error on localhost and live server. PW 2.7.3 All module settings are at their defaults apart from specifying template to search, URL field and images field. My URL field: Error message is When opening the URL of the thumbnail the module is trying to grab from it looks like this size does not exist. It seems the largest available size is: http://img.youtube.com/vi/NIMgEEASoWQ/hqdefault.jpg But is it correct that with the default settings the module is meant to check for the largest available thumbnail and grab that? Edit: another issue is the one Pete raised previously about selecting an image field to hold the thumbnail - if that field has a limit (e.g. 1 image) the limit is ignored. My preference here would be to follow the admin behaviour and replace the existing image. And folks can just have the sense not to check "All available" if they have chosen to use a limited image field.
  12. @slave: I didn't notice your produktkategorie pages are not direct children of Home. Try making a PageArray of your menu items and giving that to MSN as the root argument. <?php $nav = $modules->get("MarkupSimpleNavigation"); // load the module // make PageArray of your menu items $menu_pages = $pages->find("template=produktkategorie")->prepend($pages->get("/")); echo $nav->render(null, null, $menu_pages); // render the menu ?>
  13. @slave <?php $nav = $modules->get("MarkupSimpleNavigation"); // load the module // set options $nav_options = array( 'show_root' => true, 'selector' => 'template=produktkategorie' ); echo $nav->render($nav_options); // render the menu ?>
  14. Many thanks!
  15. My project has a page that I want to store archived versions of. This isn't for version control or anything like that - it's just a page that gets regularly updated and visitors should be able to browse the previous versions of it. So my idea is to have a page structure like this: My PageMy Page - 16 April 2016 My Page - 9 April 2016 My Page - 28 March 2016 The top "My Page" just pulls in the content from the most recent child page and then displays a list of links to all children but the most recent. To create a new version of the page an editor will create a new child of "My Page". But I don't want them to have to enter a page title - the title should always be "My Page - [creation date]". I hadn't had reason to use the "Name format for children" template option before and I thought it was going to be the solution. But now I see that it just sets the name and not the title of child pages. Which puzzles me a bit. Is this option mostly intended for if you change Title to be non-global and then remove it from the template? Wouldn't it be better if this option automatically set the title rather than the name and then derived the name from the title as per normal? Anyway, main question: is there something I can hook into to either Fill out the title field in the first step of the Add New page process (and ideally make it non-editable by the user) Or fill out the title field in the second step of the Add New page process. Then I can skip the first step via the "Name format for children" option and set the title field visibility to locked so it's not editable. This might be the better option.
  16. @cstevensjr: Do you always use the same URL or is it different for every site you develop? If it's different do you have a method for deciding what to use for the admin URL? BTW, I'm not requesting you reveal a real admin URL here.
  17. Every time I do a new PW install I pause at the Admin Login URL field and wonder if I should be doing something here to improve security. My thinking goes like this: I'd like to place some sort of obstacle to discovering the admin URL to keep out nosy-parkers and casual abusers. But I don't want to make things unnecessarily difficult for my editors, who shouldn't have to hunt out the URL or end up stuck if they need to edit the site on a device that doesn't have the admin URL bookmarked. In other words, it has to be something that can be remembered by a normal mortal. In the end I just stick with the default /processwire/ URL because it seems a good trade-off in that it's not as obvious as /admin/ but is memorable. Also, it's a word that isn't a household name to the wider public but familiar to an editor has been working with the site for a while and looking at the PW logo in the admin banner. Is there a best-practice around setting the admin URL? What are others of you doing with this? Is anyone setting admin URLs like /84tpt28hgs5y/ ?
  18. I've also wondered this, and I think it would be good to have an option in the module config to disable Ace so it can be removed altogether for those who would prefer this. The Code tab for all my hannas looks like this: <?php include($config->paths->templates . "hannas/my_hanna_code.php"); ...because I much prefer to edit hanna codes in my IDE. So I don't really need Ace bundled into the module.
  19. 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.
  20. 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?
  21. 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(); ?>
  22. 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.
  23. 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.
  24. A feature request: Sass support (specifically SCSS). Thanks!
  25. 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.
×
×
  • Create New...