Leaderboard
Popular Content
Showing content with the highest reputation on 04/02/2017 in all areas
-
Here is the scenario. You have developed a blog or news site or blog section to your site and you have created a basic tag system using a Page Reference field. How can you add related articles easily? This is one way by using Hanna code. I like this method because it gives me the choice of showing or not showing related articles and choosing the tag. My articles use a template called basic-page which includes a Page Reference field called tags. This is a multiple select field. I have created a Hanna code called "tagsearch" and given it the attribute "tag". In my textarea field it is used thus: [[tagsearch tag="fish"]] The Hanna code simply searches the title field of the tags pages for the single term and returns the pages that have that tag. I have limited the results to 8. From the results, we pluck the title field of the pages, the small image that I use for my thumbnail, and the url. However, we do not want to also return the page we are displaying, so we simply eliminate it by making sure that that none of the results have the same page name. Here is the commented Hanna code. <?php // Find the pages that use the specified tag $articles = $pages->find("template=basic-page, tags.title=$tag, limit=8"); // Start the loop foreach($articles as $article){ // Check we are only displaying articles that are NOT the current page if($article->name != $page->name){ // Add a thumbnail, but check it is there so we don't get errors if($article->image_small){ echo "<a href='{$article->url}'><img src='{$article->image_small->url}'></a><br>"; } // Grab the article title echo "<br><a href='{$article->url}'>{$article->title}</a>"; // end the check to make sure we do not show the current page } // end the loop } And that is it.6 points
-
Hi there, I created a new module called TextformatterMixcloudEmbed. It is based on the Soundcloud Embed Textformatter by Marvin Scharle and the Textformatter Youtube Embed by Ryan and is working the same way. I hope you like it! Download: https://github.com/TomasKostadinov/TextformatterMixcloudEmbed Screenshots:4 points
-
https://processwire.com/blog/posts/new-ajax-driven-inputs-conditional-hooks-template-family-settings-and-more/#new-conditional-hooks3 points
-
@tpr, I often want to work with system templates. Examples being: Add fields to the user template, and want easy access to the template from the admin menus or without having to set the "Show system templates" filter in the templates list. When editing a field, add that field to the template of a repeater field. Normally to do stuff like this you have to have $config->advanced = true in /site/config.php, but I don't want the risk of messing up the other things that this setting exposes. So I looked at making system templates visible through hooks and came up with this: // Show system templates $this->addHookBefore('ProcessField::buildEditFormInfo', function($event) { // Show system templates in templates list of Edit Field $this->wire('config')->advanced = true; }); $this->addHookBefore('ProcessTemplate::executeNavJSON', function($event) { // Show system templates in admin menu $this->wire('config')->advanced = true; }); $this->addHookAfter('Session::loginSuccess(roles=superuser)', null, function($event) { // Show system templates in templates list unless explicitly hidden $this->wire('session')->set('ProcessTemplateFilterSystem', 1); }); Is this something you think would be a good option to add to AOS?2 points
-
To add the 'country' field you can simply do this: $inputfield = $user->getInputfields('country'); $form->add($inputfield); Depending on how many fields in your user template, when building a profile edit form for the frontend it can be easier to define an array of 'ignore' fields and then add all inputfields for the user template that are not in the ignore array. Pretty sure I got this idea from some code by @Soma. // Get the fields from the user template $inputfields = $user->getInputfields(); // Don't include these fields in the form $ignore_fields = [ 'user_name', 'temp_password', 'roles,' ]; // Add the inputfields to the form foreach($inputfields as $inputfield) { if(in_array($inputfield->name, $ignore_fields)) continue; $form->add($inputfield); }2 points
-
1 point
-
Is there something like that available in PW ? I need to filter something in a repeater by its last value. Something like that: repeater.last.field repeater.first.field1 point
-
It requires a couple of steps, but so long as your pages selector doesn't return a huge number of results this should be fairly low impact: $value = 'Foo'; $all_matches = $pages->find("my_table.my_field=$value"); $first_row_matches = $pages->newPageArray(); foreach($all_matches as $match) { if($match->my_table->first()->my_field == $value) $first_row_matches->add($match); }1 point
-
I did try the Image Interceptor module, but I couldn't get it to work. Though I see that Processwire 3.0 is not listed as compatible, only up to and including 2.7. The module didn't seem to have any effect on anything. >_> Got the Image Interceptor module to work now. It does the job.1 point
-
Needs the Pages class in there somewhere. Either: public function ready() { if($this->page->template->name == 'TemplateName') { $this->pages->addHookAfter('save', $this, 'syncMobileDE'); } } Or: public function ready() { if($this->page->template->name == 'TemplateName') { $this->addHookAfter('Pages::save', $this, 'syncMobileDE'); } }1 point
-
one way would be with jquery; another way would be with a textformatter applied to the rte field, in which you could use something like simple html dom parser, to wrap those....1 point
-
Just reporting back that for my case this turned out to be very easy using just WireHttp alone and no Oauth client library needed. $http = new WireHttp(); $consumer_key = 'my_key'; $consumer_secret = 'my_secret'; $auth_token = 'my_auth_token'; $auth_token_secret = 'my_auth_token_secret'; $time = time(); $nonce = md5(uniqid(microtime())); // OAuth authorization header $http->setHeader('Authorization', "OAuth oauth_consumer_key=$consumer_key, oauth_token=$auth_token, oauth_version=1.0, oauth_timestamp=$time, oauth_nonce=$nonce, oauth_signature_method=PLAINTEXT, oauth_signature={$consumer_secret}%26{$auth_token_secret}"); // Parameters $params = [ 'member_listing' => '123456', 'rows' => '20', 'photo_size' => 'FullSize', 'return_metadata' => 'false', ]; $params_str = http_build_query($params); // Get JSON response from Trade Me $json = $http->getJSON("https://api.tmsandbox.co.nz/v1/Search/Property/Rental.json?$params_str"); Because of the circumstances of my case I can hardcode $auth_token and $auth_token_secret. But more often with OAuth you would need to get these values in a separate query and store them.1 point
-
Try seats.name=5 and year.name=2008 With page reference fields you are supposed to specify the subfield from the page that has been selected. I never actually realized that some work without specifying the subfield, but I just tested an can confirm what you are seeing. Not sure if this is really a bug or not, but I would definitely recommend always specifying the subfield (either name, title, or any other field from the selected page).1 point
-
Yeah, I had my nightmares with this situation too. There are lots of scenarios when ProcessWire could redirect your ajax requests and the graphql will not receive the query. The ones that I had encountered were: If the url ends without slash: ...website.com/graphql ==> ...website.com/graphql/ If there is now www prefix: website.com/graphql/ ==> www.website.com/graphq/ And now I guess when languages are enabled you also gotta make sure ProcessWire is not redirecting you to the respective language url of the graphql api. I haven't tested the module with the languages enabled yet, but I am sure there would be some additional caveats. Yes, that's the expected behavior. Unfortunately to support permission inheritance would be too expensive. Because it means to check template permissions of each ancestor of each returned page. I think the module is already slow and supporting permission inheritance would make it even slower. I guess I have to mention about not supporting permission inheritance somewhere in the documentation of the module. That's right, it turns out there was a bug. I pushed an update regarding the datetime field. Grab the latest version of the module and it should work properly. Yep. That's the way. I know, it's ugly. But I can't think of a less verbose way to return a single page from the api. We could, of course introduce an additional field for each template like basic_page_single or something. But I don't think it's worth it, plus it will make the schema bigger for very little gain. I totally agree. We can't allow everyone to create images. The size field of the image type creates images only if the user has an edit permission on that image field. It is still available to the users who do not have edit permission, but only for getting existing variations, and it should return null if there isn't an image variation with the requested size. Edit: By the way, thanks a lot for the feedback.1 point
-
While mostly just routine updates, this week we have a new core version on the dev branch with several tweaks and PRs. Work also continues on the Uikit admin theme framework, and more: https://processwire.com/blog/posts/processwire-3.0.58-core-updates/1 point
-
1 point
-
Fantastic video @Nurguly Ashyrov - really well put together and great English - I don't know how you come across so clearly given that you haven't spoken it in 6 years! I am really excited to start using this module. The one thing I noticed which seemed a little weird to me was that by default the skyscraper-editor (or guest) user didn't have access to fields until you enabled field level access control and explicitly gave them view access (~35:10 min mark in video). By default in ProcessWire, anyone can view a field if field level access control is turned off. Only once it is turned on are any restrictions applied. Does that make sense, or did I misinterpret something? Thanks again - this is going to be so very useful!1 point
-
Hi @mvdesign. So sorry that I could not respond earlier. I decided to make an introduction video for this module to help people that are trying to use it. But then, I never made a screencast video before, and on top of that, the last time I spoke english was 2011. So I had to take dozens of try-outs till I got something watchable. So here is the video. It shows how you would create/update pages with this module. The video is far from OK, so I will probably record another one after I get some feedback. Until then please refer to this video to learn about how the module works.1 point
-
I have a text area on a template that stores html. I think it would be a great addition if we could make the page save feature keep my spot in the text area and keep the spot of the scroll bar instead of taking me to the top of the page and starting the text area at the top. (I could have been editing a line in the middle of the box and then need to scroll down to find it again to make another change) Even better would be an update that wouldn't refresh the whole page at all but just the field contents! But a flash is ok as long as it remembers where I was at!1 point
-
Some race condition on the server with a shared session directory perhaps? In that case, enabling SessionHandlerDatabase should instantly get rid of the problem. Looking closer, two of the three IPs in the log belong to cloudflare, so if you're using their CDN to speed up the site, this could be a misconfiguration there too. Is the backend routed through Cloudflare? Could it be that there's an option to preserve cookies active? I've got no experience with Cloudflare, but I have seen some very dangerous options to that extent available with Akamai.1 point
-
Hi Sephiroth. Great start! I have been searching for an in-depth tutorial on creating modules so I was delighted to find this thread linked in ProcessWire Weekly. I started reading and adding comments for grammar and spelling and realized it would be much faster if I was able to actually edit the doc. So, I am officially offering my services as an Editor for your document. I figure this would be a great way for me to contribute back to this awesome community and help you help me learn how to write PW modules. If you are interested, let me know and we can go from there. Continue the great work!1 point