Jump to content

Robin S

Members
  • Posts

    4,928
  • Joined

  • Days Won

    321

Everything posted by Robin S

  1. @netcarver That's perfect, thanks. Getting the full URL using API methods only is surprisingly long-winded. This is the best I could manage: $full_url = $page->url; if($input->urlSegmentsStr) { $full_url .= $input->urlSegmentsStr . "/"; } if($input->pageNum > 1) { $full_url .= $config->pageNumUrlPrefix . $input->pageNum; }
  2. @adrian Thanks, but $page->httpUrl doesn't include url segments or page numbers.
  3. Is there an API method that gives the complete URL of the currently viewed page as it is known to PW? So not including any hashes or other URL changes that might have been made by Javascript (PW can't know about those) but basically $page->url + any url segments + any page numbers. Or does this have to be built manually from the other $input methods?
  4. Just used this excellent suggestion and thought I might as well post some code here. $upcoming_events = $pages->find("template=event, event_date>=today, sort=event_date"); $prev_event_month = ""; foreach($upcoming_events as $upcoming_event) { $month = date("F", $upcoming_event->getUnformatted("event_date")); if($month !== $prev_event_month) { echo "<h2>{$month}</h2>"; } echo "<h3>{$upcoming_event->title}</h3>"; // more event markup here $prev_event_month = $month; }
  5. Ryan, you're a legend! Reviewing all that documentation must have been an enormous job. Having up-to-date docs is just so valuable to the PW community so a big thank you for this!
  6. Not sure what you mean; $tagless_images are your images without tags, for images with tags you use: $mytag_images = $page->images->findTag('mytag'); Count does not belong in your if expression: ->has() returns true or false so it doesn't make sense to count it.
  7. Not sure of the cause of that error but if your PW version is >= 2.6.9 you could try the setAndSave method and see if that works.
  8. Thanks for all the great info! Lots of learning ahead of me but I love it.
  9. $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=''");
  10. 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?
  11. 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.
  12. 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.
  13. 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.
  14. This post describes a way of overwriting the created date via the API.
  15. 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).
  16. 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?
  17. @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.
  18. 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.
  19. @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 ?>
  20. @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 ?>
  21. 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.
  22. @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.
  23. 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/ ?
  24. 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.
×
×
  • Create New...