Jump to content

Macrura

PW-Moderators
  • Posts

    2,766
  • Joined

  • Last visited

  • Days Won

    40

Everything posted by Macrura

  1. Wow didn't know that; i had avoided repeater matrix in this particular scenario because the pages i use for the sections have a lot of fields, and use a 2-column layout as well; Also, i like to be able to direct edit the sections from the page tree once in a while; but certainly for simpler applications, the repeater matrix sounds awesome and i'll have to give it a go soon... Another reason why the Micro Contexts idea will still be useful is for templates that are not in a repeatable context; But you have brought up the issue of the interface, so perhaps i need to have a process module that can show the various related contexts on 1 screen...
  2. maybe the selector engine is figuring it out based on whether it is an integer and then looking at the page name (if you are using page reference)
  3. you'd need to first change the brand selector to band.name, so it would look like brand.name=adidas|nike i don't think the trailing pipe will affect anything, but you can remove it before you add the comma, using a rtrim. Alternately you can use the new selector array syntax; The skyscrapers profile is probably really old and doesn't represent the latest and greatest advances and breakthroughs that the api has to offer. I would recommend to study this blog post: https://processwire.com/blog/posts/processwire-3.0.13-selector-upgrades-and-new-form-builder-version/#building-a-selector-string-with-user-input-example
  4. ok sure - i will try and make this short and as relevant to this topic as possible, but ultimately this does relate to the age old discussion of how to implement configurable pages that has many topics and long discussions on the forum, so this problem/solution is somewhat based on researching and trying every option and arriving at this as the currently best option for creating turnkey websites: The problem: You want to implement a user interface that allows site editors to create and update page sections; in some cases these page sections may be orderable and in other cases you might want to restrict the ability of the editors to change the order. You may also want the user to be able to change from one type of section to another similar type of section with ease and not having to have some complex instructions for how to do that. One example might be a callout - perhaps there are 3-4 different types of callouts, one is a full width, and another is a split box. Another option might be a hero section where options include static image, video, or slider. The user should be able to switch the type of section type without having to create a whole new section and copy their content and prefs to the new section. They should not be required to go to the settings tab and change the template and have to go through that process. Based on these requirements, any interface that asks the user to specify the section type (template) prior to adding the new section will not work - this means no repeaters, and no page tables that use multiple templates. The solution i use is to let users add a new section to the page table, and on the section template, they can select the type of section to use (a field). The 'section type' field is a page reference (single select), which pulls the options from a hidden branch of the page tree. The sections for any page are output by checking for the existence of a corresponding php file (where the selected option's page name corresponds to the file name of the php file) in a directory in the templates folder. Each section's php file renders the section, and is a completely self contained file that includes all of the necessary code to render the section. I use a theme engine that also allows any section to inject dependencies into the header or footer, and set/modify other theme options/variables. Based on your outlined fields, you have mostly common field requirements between your sections: Title [title] Subtitle [subtitle] Multiple background images [images] Links [links table or repeater] Title for area [title] Paragraph of text [body] Background image [images - use first one] Bullet points [body] Image [images - use first one] Links [links table or repeater] List of feature with a title/description for each [features repeater] Image [images - use first one] Text [body] Link [links table or repeater - use first one] News section title [title] Title [title] Description [body] Link/link text [links table or repeater - use first one] Description [body] List of images/links [possibly repeater, or images extra with url field?] The micro contexts system would simply allow you to change the field labels, descriptions, notes, order, visibility and required based on the page reference selection for the section type...
  5. yes, thanks for the clarification - ultimately this module should be improved to allow for showing help topics on their own pages, and a better help overview page where the contents are all listed under categories... i probably can't work on that till July, but i do expect at some point to make this module better and as you say link to specific help topics.. for now though you can use the hash feature that was coded by @justb3a :
  6. This code can be placed into any generic site utilities module and you can add the hook in the init(); you can for example take the hello world module and clone it, rename to SiteUtilities, and then you can throw all of your custom stuff in there, instead of doing independent modules for everything.. $this->pages->addHookBefore('save', $this, 'addImageDataAttributes'); public function addImageDataAttributes($event) { $page = $event->arguments[0]; $ta_field = 'body'; // change to your editor field that holds the images $img_field = 'images'; // change to the name of the images field if(!$page->$img_field || !$page->$ta_field) return; $html = $page->$ta_field; if (strpos($html,'<img') === false) return; //return early if no images are embedded in html $dom = new \DOMDocument(); $dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8')); $images = $dom->getElementsByTagName('img'); if(!$images->length) return; // not needed? $imgCount = 0; foreach ($images as $image) { $img_url = $image->getAttribute('src'); $path_parts = pathinfo($img_url); $imgName = $path_parts['basename']; $sysImage = $page->$img_field->get("name={$imgName}"); $width = $sysImage->width; $height = $sysImage->height; $image->setAttribute('data-width', $width); $image->setAttribute('data-height', $height); $imgCount++; } if(!$imgCount) return; $page->of(false); $page->$ta_field = preg_replace('/^<!DOCTYPE.+?>/', '', str_replace( array('<html>', '</html>', '<body>', '</body>'), array('', '', '', ''), $dom->saveHTML())); $page->save($ta_field); $this->message("image links updated with data attributes."); } This has been tested and works, but it will only retain the data attributes if your CK editor settings allow it..
  7. i like it a lot – i think anyone who has a firm grasp on this can really thrive in PW in so many ways...
  8. ditto, i was basically implying that the code may be adjustable or tweakable within interceptor, to add your data attributes; the import external images shows how to grab any image tag using dom parser; i can take a look and see how hard it would be to add data attributes to the resultant image since the mod already switches out the href; come to think of it, most of the code for that came from Adrian's wordpress migrator, so there could be something in there also
  9. I have used that technique (as described here: https://processwire-recipes.com/recipes/use-different-sets-of-template-files/ ) for developing a whole new frontend while the site was live and then replaced the whole templates directory when the new one was done...
  10. @cjx2240 here's my 2cents: - for those configurable pages, i use a pagetable, in combination with the Micro Contexts module... this allows me to have 1 template for all of those items but to hide/show fields and change their order, descriptions, labels, notes and even conditional hide/show based on the 'type' of widget (e.g. section). this is working really well for me because on 'turn-key' site, you never know how many custom sections you will need to build, and it would be a drag to have to keep creating new templates; in this system you just need to add each section as an option (e.g. page reference for the section type) and then load the corresponding file using some code like this: if(count($page->sections_pt)) { $sections = ''; foreach($page->sections_pt as $section) { if(file_exists('./partials/sections/section-' . $section->widget_type->name . '.php')) { $viewBag['widget'] = $section; $sections .= "\n" . wireRenderFile('./partials/sections/section-' . $section->widget_type->name, $viewBag); } } $content = $sections; }
  11. @bernhard - sure, let me know what context this applies to - for example if you are viewing the help tab, or help modal on the page editor, or showing the help topic in the process module? I haven't worked with panels yet, so if you have any further details on how and when that comes into play, let me know how to replicate the issue etc..
  12. i keep everything for the front end in the templates folder, since a lot of modules and such use the templates directory as the assumed location of the fonts, js, css files... i tried a long time ago to keep some things outside of templates, but it didn't really help and was somewhat annoying to deal with... i can't see any reason why templates folder can't hold everything, plus then you can use alternate template folder setup for testing and development (like templates-dev)... and have a completely separate independent copy of all those things
  13. I think if you make a textformatter is should not be that hard to grab the images and add your data attributes; maybe look at image interceptor and/or the external images modules, and see if you can get the tags by regex or using dom parser...
  14. usually you just need save the new field first, then get the field and do the extra stuff to it, i think that's how i did a page select in the admin help module, IIRC
  15. I have the same issue, if the image is too large, just forever spinner...
  16. not really a solution, but i use the limit page table module to prevent users from trashing items in page tables, and use the extra actions (hide, unpub); so basically the users can't trash pagetable pages – if they don't want those pages anymore then they can unpub;
  17. Since Polymer is a front end library, there is no restriction by ProcessWire in terms of how you build your front end, therefore if i'm not mistaken you can use it.
  18. @fredmv i would recommend contacting Ryan again to request access to the ProCache forum. If you have your receipt email from the shop, you may be able to reply to that, in case the PM doesn't work. Note that Ryan is only typically addressing the pro module forums on Sundays.
  19. Hi @zenboy - welcome to the forums! Since this post pertains to the Profields, you do need to post this issue under that board (Profields, Repeater Matrix).
  20. The latest version of Admin Help module allows you to add a field to any help doc called help_header, which is then prepended to the edit form, for the template that this is enabled for. I use this for exactly the purpose you describe here, as well as putting a lot of instructions at the top of the page edit for certain template/page types; does help a lot and cuts down on support calls.. Alternately you can achieve this with a custom hook/function in your ready.php, for example hook into ProcessPageEdit::buildForm, and then prepend some markup depending if the conditions are met
  21. i've been using the enhanced icon select in my selectize template and field tags module, which has served well for the past year; http://modules.processwire.com/modules/selectize-template-field-tags/ but your module looks like possible improvement..thanks!
  22. have you tried setting the get var programmatically in the module (e.g. $input->get->id = $this->user->id)?
  23. @MaryMatlow what version of PHP are you using? You do need to be on 5.4+
  24. can you provide screenshots of your templates folder, and the screen showing where you entered the alternate template file name. other considerations, are you using delayed output, do you have _main.php... also pls. post the debug message, url etc..
  25. We have 2 sites running no problem on BlueHost. Have you checked the permissions on the files?
×
×
  • Create New...