-
Posts
5,039 -
Joined
-
Days Won
340
Everything posted by Robin S
-
Image field in User template not behaving normally
Robin S replied to Robin S's topic in General Support
Are you sure that's true? Good to know if it is, but tried testing it by putting die() in my init.php and admin is unaffected. -
Image field in User template not behaving normally
Robin S replied to Robin S's topic in General Support
Thanks. Probably the easiest thing for me is to put: $user->of(true); in my templates' auto-prepended init.php and then I can use the field consistently across $user and $page. (edited for clarity) Some of Ryan's comments in the old thread you linked to make it sound like having output formatting off for the user template is deliberate, but then the docs say and which make it sound like $user should be essentially the same as $page and will have outputting formatting on by default. -
Just struck this also. @Chris is right about the source of the problem... $storage->parent = $this->pages->get('/admin/'); ...should instead be... $storage->parent = $this->pages->get(2); Making the change above does allow the module to be installed but first you have to delete the fhStorage template from the failed installation attempt. And this isn't straightforward because the system flag is set, and can only be removed via the API. To do this... $t = $templates->get("fhStorage"); $t->flags = Template::flagSystemOverride; $t->flags = 0; $t->save(); Then the template may be deleted via the Admin (or the API).
-
I have added an image field "avatar" to the user template. The field settings are "Maximum files: 1", "Formatted value: Single items (null if empty)". So I believe I should be able to get the URL of this image in my template with $user->avatar->url But this returns /site/assets/files/1217/ If I add the avatar field to any other template besides the User template I can get the URL as expected. For the user template if I use $user->avatar->first->url I get the URL okay. So it's like image fields added to the User template don't honour the "Formatted value" setting. Has anyone else experienced this? If so I guess it's bug and I'll file an issue on Github. Edit: If I get a specific User page it works normally $pages(1217)->avatar->url So it's just an issue when trying to get the image from the User object. Is this difference from the Page object likely to be intentional?
-
any auto page title generator module existed ?
Robin S replied to adrianmak's topic in General Support
Answered recently here. -
I believe I have sendmail set up correctly in my localhost environment, and I can send mail fine with WireMail like: wireMail('my@email.com', 'some@email.com', 'Message Subject', 'Message Body'); But when attempting to use the core "forgot password" feature WireMail throws an error: Invalid email address (processwire@myvirtualhost) Is there a config option to set this default "from" address to something that is better formed?
-
@bernhard Just wanted to say thanks for this module. I prefer it to the Helper Field Links module because the link doesn't create any extra space in the inputfield, which is useful when setting the layout of inputfields as I see almost the same interface as site editors will see. Cheers!
-
Another way you could do this (code style may not be to your taste): <?php $pagesWithImages = $pages->find("filter_image!=''"); ?> <?php foreach($pagesWithImages as $p): ?> <?php foreach($p->filter_image as $filter): ?> <div class="filter-box" style="background-image: url(<?= $filter->url ?>);"> <div class="uk-overlay uk-overlay-hover uk-position-cover"> <div class="uk-overlay-panel uk-position-cover uk-overlay-background uk-overlay-fade uk-flex uk-flex-center uk-flex-middle"> <a class="hover-btn" href="<?= $p->url ?>"><?= $filter->description ?></a> </div> </div> </div> <?php endforeach; ?> <?php endforeach; ?
-
I'm don't follow exactly what you're wanting to do. For instance, child's parent's children is the same as just children and "new" and "before" is ambiguous. But maybe this works... $johns_comments = $pages->find("template=comment, comment_username=John"); $comments_after_johns = new PageArray; foreach($johns_comments as $j_comment) { $comments_after_johns->add($j_comment->nextAll); } Not tested.
-
@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; }
-
@adrian Thanks, but $page->httpUrl doesn't include url segments or page numbers.
-
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?
-
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; }
-
New ProcessWire 3.x API Reference Documentation
Robin S replied to ryan's topic in News & Announcements
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! -
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.
-
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.
- 1 reply
-
- 1
-
-
Thanks for all the great info! Lots of learning ahead of me but I love it.
-
$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=''");
-
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?
-
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.
-
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.
-
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.
-
This post describes a way of overwriting the created date via the API.
-
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).
-
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?