OLSA

Members
  • Content count

    59
  • Joined

  • Last visited

Community Reputation

37 Excellent

About OLSA

  • Rank
    Full Member

Profile Information

  • Gender
    Male

Recent Profile Visitors

1,947 profile views
  1. Hello Brian. Just saw only two files and here are small suggestions for better practice ( pages->find inside foreach and count inside for loops). insider-home.php // line 2. foreach ($pages->find("articleInsider=1") as $article){ ... } better is this: $articles = $pages->find("articleInsider=1"); foreach ($articles as $article){ ... } or article.php // 46. line for ($i=0; $i < count($titleArr); $i++) { ... } to this $c = count($titleArr); for ($i=0; $i < $c; $i++) { .... } It's not problem if do this inside if statement eg. if( count($pages->find...) > 1 ). Regards.
  2. Hello Vikestart, for that you can use "tags". To create "tags" there are many options and here is one: 1) create template "tags" 2) create template "tag" with only deafult field "title" 3) create field "tags", type page ( my suggestion is to use Lostkobrakai module Chosen Select ), and add it to "movie" template *** note: for page field "tags" set as parent page "Tags" (example below) As example here is some page tree: - Home - About Us - Movies --- Horror ------ Some Horror Movie (eg. template "movie" with your custom fields - and one is field "tags" (3.) ) --- Thriller ------ Some Thriller Movie ( -//- -//- -//- ) - Contact - Tags ( template: "tags", page/settings: hidden ) --- Horror (template: "tag") --- Thriller (-//-) --- Scifi --- etc After that inside movies set "tags" for every movie (one or multiple tags per movie). 1) Here is example how to get Some Horror-Thriller inside your category Thriller's: // on page "Thriller" $search_term = $sanitizer->text($page->title); // thriller $items = $pages->find("tags.title%=$search_term, sort=-sort"); // here you can add more precious filters... 2) You have some "Tags Cloud" widget (eg. in some sidebar) <?php // tags cloud $tags = $pages->find("template=tag, include=all");// include=all because of hidden parent ?> <div class="widget tags-cloud"> <?php foreach($tags as $tag): ?> <a href="<?php echo $tag->url;?>"><?php echo $tag->title;?></a> <?php endforeach; ?> </div> Maybe links inside "tags-cloud" are little confused, eg. "my-website.com/tags/horror" but that's part will be more clear if you watch main part inside tag.php and tags.php templates (below): // tag.php $search_term = $sanitizer->text($page->title); $items = $pages->find("tags.title%=$search_term, sort=-sort"); // tags.php $tags = $pages->find("template=tag"); $items = $pages->find("tags=$tags, sort=tags.title"); regards p.s. this principle is used here on some of my testing website (at sidebar column is tags-cloud widget)
  3. Hello, my problem was that I get blank page after manual upgrade from 2.8.0/2.8.35 to 3.x. on localhost (Windows). Also there is no errors inside log files (php, apache... site/logs). Problem solved after addition in top of config file (site/config.php): namespace ProcessWire; One of the first thing what I done (after upgrade and blank page) was that I added this in site/config.php : // no need to add this!!! // disable module compilation $config->moduleCompile = false; // disable template file compilation $config->templateCompile = false; but did not pay attention on config file, and "configure" itself . Regards. p.s. maybe this should be noted in this page
  4. Hello, don't want to open new topic, but can confirm similar problem. In localhost, I have problem to upgrade from 2.8.35 to 3.0.42 (also unsuccessful to 3.0.51), but clean install 3.0.42 go without any problem. I have totally blank page and don't have any error inside log files (php, apache, mysql and also PW error log file are clean)!? Also try many reloads (Ctrl+F5) but without success. A few details about my local server: PHP 5.6.16, MySQL 5.7.9, Apache 2.4.17, Wamp 3.0.0 Regards. EDIT: solved problem after addition "namespace ProcessWire;" on top of the site/config.php (more details here)
  5. Hello for all, I can't find solution how to manipulate with image tags field (as object) inside admin/edit using hooks. My problem that I need to use multilanguage predefined tags (I like to store pages ID from some another page tree). Also I know that there are other solutions (eg. repeatable field with image field and some page field for tags, or using page table), but in my case I like to use hook inside custom module for that job. I try with InputfieldImage::render, and InputfieldFile::render... but with that I can't get/"touch" values from image tags field. Only working solution what I have right now is using ProcessPageEdit::execute but with that can manipulate only with tags value - is there any other better elegant solution to manipulate with image tags field (as object, as example set class, add readonly attribute, append some html...)? $this->addHookBefore('ProcessPageEdit::execute', function(HookEvent $event) { $page = $event->object->getPage(); foreach ( $page->fields as $field ) { if ($field->type instanceof FieldtypeImage && $field->useTags) { $imageField = $page->get((string)$field->name); // there are multiple images foreach($imageField as $f){ $f->tags = '...'; // tags value only } } } }); Regards and thanks. EDIT: Now it's clear to me what can be done. With this ("simple" variant) is possible to add class to wrapper, manipulate with value, but for more than that need to override core InputfieldFile module (inside site/modules). Also there is always option to use javascript for some manipulation.
  6. I assume that you know how to show field label on front (there is few options), one option is: echo $page->fields->summary->label; // for field with name "summary" But today I had a problem how to show field label depending on the current page template (example: in template "member", "summary" field label is override to "Personal info"). In that case, previous example will not give you desired result. To get field label in that case, this is what works: $page->getField('summary')->label; // result would be "Personal info" Maybe this is helpful for someone. Regards.
  7. Hello for all, don't know if this is interesting to someone: //pseudocode example (inside some module) //we have some pages array (5 to 10 pages) wire('pages')->find('id=1111|2222|...'); // 0.050s, and ordering is not like selected wire('pages')->getById( array(1111,2222,...) ); // 0.035s, and ordering is exactly like selected It seems that query with "getById" is somehow faster and ordering is correct. Regards
  8. Hello, I have the same problem today and done this to solve that: $your_field->label = ''; //first need to set field label as empty string (important!) $your_field->skipLabel = true; //works only if the label is set to empty string regards.
  9. I have working solution on PW 3.09 with this inside Extra Allowed Content: div(*)[*]{*} iframe(*)[*]{*} But my opinion is that HTML Purifier strip some tags (like "data-oembed-url" and others) and to get working solution HTML Purifer need to be off. Also edit works (2 clicks, open popup with url input).
  10. Hello, yes that needs to be done to get visible plugin button inside CKEditor toolbar (sometimes it's problem to find right "call"/"trigger", eg. plugin name "btgrid", but to get toolbar button need to insert/write "Btgrid"). To solve problem with cleaning divs write this below inside Extra Allowed Content: div(*)[*]{*} Or next example will allow to use <p class="...">, <a class="...">, <div class="...">. p(*)[*]{*} a(*)[*]{*} div(*)[*]{*} All this examples also works if ACF or Purifer switched on. Regards.
  11. Hello abmcr, for that I created few modules and try many options to get best result. But also here is example with PW default: 1. create independent page tree structure (eg. "Widgets/Addons" or...) 2. In that structure categorise widgets/addons as child of "blank" template Widgets (template: addons) |- Sliders (template: blank) -- Some slider (template: slider-1) -- Some another slider (template: slider-2) |- Call To Actions (template: blank) -- Some Call To Action widget (template: call-to-action-1) |- Banners (template: blank) -- Some banner (template: banner) |- Text and Image (template: blank) -- Some Text and Image block (template: text-image-1) -- Some another Text and Image block (template: text-image-2) Etc... NOTE: Use nice Bernhard module TemplatePreviewImages, or here is link to version where I added few additions. 3.1. Go to your main pages (Home, Category etc...) and add field type page with name "widgets" or "addons", parent page for that field set as page "Widgets" (from 1). With this option you can add rows of widgets to your main pages. OR 3.2. If you want to use positions (top, left, right, bottom etc...) than on your main pages (Home, Category etc...) add field type repeater "Blocks" with fields : "position" (select), "widgets" (page field, 3.1), "show" (select, with options: only-this, only-childs, default (this and childs)). Also all this examples need some logic, and at the end, in your templates you can call widgets like in this example: <?php if(isset($pos['left'])): ?> <div class="col-md-3 columns"> <?php renderWidgets($pos['left']); ?> </div> <?php endif; ?> Regards.
  12. Hello for all, but first thanks to Bernhard for this module! I also created something for similar usage (layout switcher, first image), but also do some additions to this nice module (second image). Here in attachment is TemplatePreviewImages module version where I added some options: thumbnails creation (before usage need to create "thumbs" folder eg: "template/images/TemplatePreviewImages/thumbs) can use any kind of image extension (jpg, jpeg, gif, png) zoom option to preview (using PW integrated jQuery UI ) can restrict module to works only inside desired page tree Regards. TemplatePreviewImages.zip
  13. Hello for all. I am also having same problem with multilanguage in PW 3.0.17. Translation of static strings doesn't work if "view" file is in subfolder. But one thing what I really don't like is template compilation - that gives me more problems in development than benefits. Also when I do this: $config->templateCompile = false; or $config->moduleCompile = false; or switch off template compilation in template settings, I get this : "Call to undefined function __()" or "Call to undefined function _x()" Also there is one old topic about "PW slow in backend" and that is my problem after ~2.7 upgrade. Because all of that probably I will back to PW 2.6 ... 2.7 System: localhost, win7 64b, wamp 3.0.0, apache 2.4.17, php 5.6.16 Regards.
  14. I had this problem today and solved it. In my case I had multiple pages with children, and want to show parent pages titles as group labels, and their child pages as group options. // $f = $this->modules->get('InputfieldSelect'); /* here we have some array of pages and foreach loops */ /* inside inner foreach fill $group_options array */ $f->addOption( $group_label, // $parentpage->title (I had troubles here, use var_dump to check that value!) $group_options, // $group_options[$childpage->id] = $childpage->title $opt_attr // array for option attributes ); If this is confused, here is part from some my custom field module where parent pages use "blank" template: $f = $this->modules->get('InputfieldSelect'); $opts = wire('pages')->get(1078)->children(); foreach($opts as $opt){ if($opt->template->name == 'blank' && $opt->numChildren()){ $group_options = array(); foreach($opt->children as $option){ $group_options[$option->id] = $option->title; // <= main part to get group options } $group_label = $opt->title . ''; $f->addOption($group_label, $group_options, array()); } } $f->attr('name', $name . '_widget[]'); $f->attr('value', $widget); Regards.
  15. Hello Christophe, old topic, but today one my client asked me the same question, and my answer was - insert caption at the end, as last step in content edit. Insert image(s), write some text, and when finish all, go back to image(s) and select and in popup check caption and write captions. Short answer: insert captions at the end. regards