-
Posts
4,928 -
Joined
-
Days Won
321
Everything posted by Robin S
-
I'm looking for examples of modules (but not Fieldtype modules) that create and query their own custom table in the database. Hoping to learn from these how to incorporate the use of a custom table in one of my own modules. These are the modules I have found so far: http://modules.processwire.com/modules/process-redirects/ http://modules.processwire.com/modules/template-parents/ The simpler the modules the better because my knowledge of SQL is nearly zilch.
-
find() would also work here: $primary_tags = $article->article_tags->find("id!=1336|1337|1338|1339|1327|1326|1328"); $secondary_tags = $article->article_tags->find("id!=1042|1043|1044|1340|1341");
-
The key thing is to load the select options via AJAX. There are are jQuery plugins that can help you do this, for example: http://plugins.krajee.com/dependent-dropdown/demo Edit: a couple of other examples... http://www.appelsiini.net/projects/chained http://tutorialzine.com/2011/11/chained-ajax-selects-jquery/
-
Have you set up URL segments for the home page template? See Ryan's post where he talks about the home template:
-
Me too; beautiful work. Love that grain - looks like film but I'm guessing not in this day and age? Maybe clicking the last image on each page could link to the next page?
- 12 replies
-
- minimalist
- minimalism
-
(and 4 more)
Tagged with:
-
It works for me even when the field is inside a fieldsettab: Incidentally, the ability to edit individual fields like this is new to me. How did you discover it, and is it documented in the code anywhere? I'm curious if there are other hidden tricks like this.
-
Try turning off HTML Purifier for the field also. With ACF and HTML Purifier off everything works for me the same as in the demo. I would say no if it requires having ACF and HTML Purifier off. These are pretty important or else careless editors can paste in all kinds of rubbish. And "Extra Allowed Content" should be kept to an absolute minimum - the allowances @OLSA suggested are so broad (plus you actually need other elements like iframe) that it's tantamount to turning ACF off altogether. But if there's a way to get it working with a reasonably strict ACF and HTML Purifier then it would be cool. Another thought: you could set up Hanna Codes for the different embeds, or even a single clever Hanna Code for all embeds that parses the URL and determines the markup needed for the embed. That would be cleaner and easier to lock down. And there is the Textformatter OEmbed module too.
-
Just throwing out an idea: maybe some JS via AdminCustomFiles that appends "&modal=1" to links in the pagetree depending on if window.location.href contains "&modal=1"? You'd have to find a way to re-init the script for each AJAX load in the pagetree though. Maybe you could to follow the same principle in PHP with a hook to the pagetree render and $_SERVER['REQUEST_URI'] ?? Not sure if that would work.
-
How to create reading book site with ProcessWire?
Robin S replied to Hector Nguyen's topic in Getting Started
I think PageTable (and Repeater / Repeater Matrix) will not scale up to the number of chapters expected. But if chapters are child pages of a book then the Lister mode of Batch Child Editor would be a good way to sort/find/manage large numbers of children: -
@Jonathan Claeys Please provide an example of the code you are using to try and get your media image URL. I haven't used Media Manager, but looking at the documentation for outputting to the front-end there are a couple of things to be aware of: 1. A Media Manager field returns an array (specifically a 'MediaManagerArray') so you need to treat it as such in your template even if it contains only a single media item. The docs suggest looping over it, but if a MediaManagerArray is also a WireArray (the docs aren't specific about that) then you could use other API methods to get items such as first() or get($key). 2. The media itself (an image in your case) is contained in the media property of an individual MediaManager object. So you need to use methods like url or size() on the media property and not on the MediaManager object. Assuming that a MediaManagerArray is a WireArray and that your Media Manager field is called my_media_field: $media_manager_array = $page->my_media_field; $media_manager_object = $media_manager_array->first(); $image_object = $media_manager_object->media; $url = $image_object->url; echo "<img src='$url'>"; This is just to give you the idea, and is more verbose than necessary.
-
Complex and unpredictable page structure
Robin S replied to spacemonkey95's topic in Getting Started
I think you'll find Repeater Matrix provides the best UI for what you want to do. It gives you the flexibility of multiple page (block) types like PageTable but with the convenience of seeing all the block content together within Edit Page. -
Module config: keep checkbox unchecked
Robin S replied to Robin S's topic in Module/Plugin Development
This is great, thanks. I see now we need to save complete config data not just one field. $this->modules->setModuleConfigData($name, $config); ^ This didn't work for me, but the following did: $this->modules->saveModuleConfigData($name, $config); -
Module config: keep checkbox unchecked
Robin S replied to Robin S's topic in Module/Plugin Development
Is there a different/better way to do that besides what I'm doing already? -
Module config: keep checkbox unchecked
Robin S replied to Robin S's topic in Module/Plugin Development
While I don't have much experience with the old approach, I think one of the main differences between the new and the old approach is the way values and defaults are set to the config fields. In the old approach you set defaults in an array and these were merged with user-saved data from the DB into a $data array. And for each inputfield you typically set the value with $data['some_key'] which could be either a default or a user value depending on if that field had a value in the DB . With the new approach the ModuleConfig class takes care of setting the value to the inputfield. It's an added convenience but it also takes it out of your hands if you want do do something out-of-the-ordinary for a particular inputfield. With the new approach, any value you set to the field is only taken as a default that may be overwritten by a user-saved value. In the blog post that introduced the new config class Ryan seems to confirm this: So now that I look at the first example again, I don't think it is this line that makes the checkbox unchecked... $field->attr('checked', ''); ...rather it's the fact that the field value is not set from the $data[] array so it never gets any value from the DB and reverts to the default state for a checkbox (unchecked) on each load of the config page. This wouldn't be possible with the new approach because values are set 'behind the scenes'. Not sure if it constitutes an issue though, maybe just requires a different approach. This is how I've solved it for now, which seems okay: public function init() { // Reset checkbox $data = array('my_checkbox' => ''); $this->modules->saveConfig(get_class($this), $data); } -
Module config: keep checkbox unchecked
Robin S replied to Robin S's topic in Module/Plugin Development
Thanks, but setting the value does not override a user-saved value either. Easier to see for another fieldtype because a checkbox is unchecked by default. But for a text field, if I set... $f = $modules->get('InputfieldText'); $f->name = 'test'; $f->label = __('Test'); $f->value = 'red'; $inputfields->add($f); ...then 'test' will show 'red' on the first config page load but if the user changes this to 'blue' then this is what sticks. -
I'm using the newer approach to module config that extends the core ModuleConfig class. I want to include a checkbox in my module config, but I want to force it to be unchecked even if the user has checked it. The reason being, the checkbox is not a setting but just an indicator for if some code should be executed. I look for the checkbox in the post data and if it's checked I execute some code, but on each load of the module config page the checkbox should be unchecked again. Any suggestions on how to do this? I had a look at the PageimageRemoveVariations module which does something similar with a checkbox... $field = $modules->get('InputfieldCheckbox'); $field->attr('name', 'remove_all_variations'); $field->label = __('Remove all Imagevariations to clear the images-cache sitewide!'); $field->attr('value', 1); $field->attr('checked', ''); $field->columnWidth = 65; $form->add($field); ...but that module uses the older approach to module config. When extending ModuleConfig it seems that setting the 'checked' attribute does not override the state of the checkbox that is stored in the DB.
-
Best thing would be to strip it back to basics to try and narrow down the problem: Remove any textformatters applied to the field. Try removing all the content from the field. Try the simplest template file possible, that just echos the field with no prepended or appended files. Try adding the field to a new template that doesn't contain any other fields (besides title) and see if you still get the problem there.
-
There isn't a PW module that will give you a front-end RTE out-of-the-box. But seeing as it is front-end it doesn't need to be PW-specific; I'm sure there are many JS scripts that turn a textarea into an RTE with varying levels of functionality. This post suggests it wasn't difficult to get CKEditor running on the front-end. I have my doubts about how easy it will be to get images embedded in a front-end RTE. I think it would be better to keep images confined to a dedicated field if possible. The Jquery File Upload module could be useful for handling the image uploads - it can do client-side image resizing. If you want to try and get image embedding working with the native PWimage plugin there is a thread about it here.
-
Saying an inputfield does not support AJAX loading often just means the inputfield doesn't initialise properly when it is added via AJAX. Probably because it only initialises on dom ready: $(document).ready(function() { initialiseMyInputfield(); }); But if there is an event fired when a new repeater item is added the author of the inputfield module can update it so it will support AJAX loading: $(document).ready(function() { initialiseMyInputfield(); }); $(document).on('repeaterItemAdded', function() { initialiseMyInputfield(); }); But in InputfieldRepeater.js I don't see events being triggered for repeater item add, sort, delete, etc that we can monitor for.
-
I think that is what this reply covers: GAPI looks like a nice interface for accessing Google Analytics stats.
-
I agree that repeaters should be firing events, especially on AJAX add. Otherwise how are JS-powered inputfields in the repeater items meant to initialise properly? Currently there are problems like this:
-
I managed to get the Embed plugin working by following the steps you outlined (adding all dependency plugins, manually adding toolbar button), and then also: Uncheck "Convert div tags to paragraph tags" Set "Use ACF?" to "No". I suppose you could keep ACF active but then you would have to add all the elements/attributes/classes that could potentially be inserted by the plugin into the "Extra Allowed Content" field. Looking at the Embed plugin source it only adds div[!data-oembed-url] as allowed content, but when you check the markup that is added for a YouTube embed (for example) you see a lot of other markup besides the div. There also something going on regarding allowed content in the Widget plugin but I found it difficult to decipher.
-
Looks like the markup for post-headline is set here: https://github.com/kongondo/Blog/blob/master/MarkupBlog.module#L916 This should work I think: $out .= "<$h class='post-headline' style='background-image:url({$page->blog_images->first->url});'><a href='{$page->url}'>{$page->title}</a></$h>"; You may want to resize the image - see the API methods for this. There is a support thread for the blog module. I believe @kongondo is away at the moment but if you post questions there other users of the module may have advice.
-
I'm not familiar with the blog module, but I assume that "blog_images" is an images field in the blog post template. If so, you don't want to iterate over the images in that field but rather you want to iterate over the PageArray of blog post pages. So something like: <?php $posts = $pages->find("template=blog_post"); foreach($posts as $post): ?> <div class="blog-post"> <div class="post-thumbnail" style="background-image:url(<?= $post->blog_images->first->url ?>);"> <h3><?= $post->title ?></h3> </div> Other summary content here... </div> <?php endforeach; ?> No doubt the blog module has some cool features, but it's not difficult to build blog functionality into your website using the basic PW fields and no module. Give it a go! That way you'll know exactly what's going on behind the scenes, learn about several different field types, and buzz-out when you see how easy PW makes it to build whatever is in your head.
-
Yes. In the example... $authors->sort("articleCount"); ... $authors is the PageArray (WireArray) and "articleCount" is the property we sort on.