Leaderboard
Popular Content
Showing content with the highest reputation on 07/23/2017 in all areas
-
Yes, planning on this. May not be in the initial public/dev branch version though. Most definitely. I think that part of it should already work, but have not spent time testing it yet. That's probably one of the next things I'll be testing here, as this would be needed before adding it as a core module. It will work like the existing template/field import, i.e. you'll be able to un-check certain updates that you don't want to occur. Though for applying granular updates, the JSON copy/paste is really nice, as you can also just modify the JSON directly too. Not planning to pursue that. This is purely about page import/export. If it needs a particular Fieldtype module to be present in order to import a field, it'll let you know of the prerequisite. The info about required Fieldtypes are stored in the export, so that the import can look at that before attempting import. This one has already been in the core for awhile. See Setup > Templates, then see the Export/Import buttons at the bottom. We have the same for fields as well.5 points
-
Update: Runtime Markup Version 0.0.3. Changelog Added support to render PHP, JavaScript and CSS files Thanks to @bernhard for the ideas. Please note: Please read the notes that accompany the field settings. For PHP, you can choose to render files (recommended) vs paste code. JavaScript and CSS work with either PHP rendering method (above). These are optional to use. For each of the 3 file types above, if you only have one file and this is named identical to your field, you can select an option to have those rendered/added. For example, if you have a RuntimeMarkup field called 'my_field', you can have a 'my_field.php', 'my_field.js' and 'my_field.css' automatically rendered/added. However, if you want to render multiple files and/or these are named differently, select the option that indicates the files have different names. In that case, enter comma-separated file names. For example, for CSS: my_css, styles/my-other-css-file. Using this option, you can include external JavaScript libraries for use on your page if you fancied it. The above can be mixed and matched, e.g. PHP file could have name identical to field but JavaScript are multiple files with different names and CSS multiple file names, one of which could share a name with your field. All files must descend from either of the root paths /site/templates/ or /site/modules/. It is OK for files to be in sub-folders, as long as those descend from one of these root paths. There is a setting to indicate root path. Only one root path can be used at a time, i.e. it applies to all file types. .php, .js and .css extensions are assumed and do not need to be specified with the file names. PHP files such as .inc will need to be input as such, e.g. my_code.inc,includes/my-more-code.tpl. Errors will be shown if files not found. In your rendered PHP file, you have access to $page and $pages. This means you do not need to get the page being edited first to use it as the current page. For frontend, only pasted PHP code option is supported. My take is that this module is primarily used for the backend. Use of the render files option is geared for creating complex and/or more flexible backend apps as opposed to frontend usage. I have no intention of changing this behaviour. Currently available on dev branch only. Please test and let me know (with Listers, etc as well, thanks). Screenshots Backend Settings Backend Output3 points
-
I do something similar to @szabesz but I found that that I had to use a different name (anything other than 'mystyles') to get this working. Whatever I did, the original one at: /wire/modules/inputfield/inputfieldCKEditor/mystyles.js would always take precedence over my custom one at: /site/modules/InputfieldCKEditor/mystyles.js So for my body field found at: Admin > SetupFields > Edit Field: body > [select input tab] ...I did this: ...and in mystyles.js: /** * mystyles.js */ CKEDITOR.stylesSet.add( 'customstyles', [ // <<<< MY CUSTOM NAME { name: 'Generic List', element: 'ul', attributes: { 'class': 'generic-list'} }, { name: 'Inline Code', element: 'code' }, { name: 'Inline Quotation', element: 'q' }, { name: 'Left Aligned Photo', element: 'img', attributes: { 'class': 'align_left' } }, { name: 'Right Aligned Photo', element: 'img', attributes: { 'class': 'align_right' } }, { name: 'Centered Photo', element: 'img', attributes: { 'class': 'align_center' } }, { name: 'Small', element: 'small' }, { name: 'Deleted Text', element: 'del' }, { name: 'Cited Work', element: 'cite' } ] ); Now I can create a list in CKeditor, then once I select this newly created list, an extra option is now in the styles dropdown to let me add a class of 'generic-list' that persists after page save without being stripped out. As I said, I tried many combinations and it just wouldn't work unless I didn't use the term 'mystyles'. Regarding that, like in my example, my custom class only appears in that dropdown after I've actually selected a list. Regarding this part, if you get the first part above working (i.e. a custom mystyles.js working), you can then chose whatever class names you want for the image align.2 points
-
Regarding your first issue: and in mystyles.js: CKEDITOR.stylesSet.add( 'mystyles', [ { name: 'Warning Paragraph', element: 'p', attributes: {'class': 'uk-alert-warning', 'data-uk-alert': ''} }, { name: 'Success Paragraph', element: 'p', attributes: {'class': 'uk-alert-success', 'data-uk-alert': ''} } ]); This setup works for me in ProcessWire 3.0.62. Is it what you are looking for? Also, something like this is my config-body.js: I have not yet worked with contents.css/contents-inline.css, it is still on my todo list...2 points
-
<?php /** * getFieldsetOf * * for ProcessWire * * gets fields inside a fieldset of pages or templates * choose to retrieve values * * @param Template|Page $context the page or template * @param String $fieldsetName name of the fieldset * @param bool|boolean $collectValues want to collect values of the pages fieldset? * @param string $fieldsetCloseIdentifier default: '_END' * @return FieldsArray|WireData returns FieldsArray or if data wanted, WireData */ function getFieldsetOf($context, String $fieldsetName, $collectValues = false, $fieldsetCloseIdentifier = '_END') { if ($collectValues === true && $context instanceof Page) { $collectedItems = new WireData(); } else if($context instanceof Template) { $collectValues = false; $collectedItems = new FieldsArray(); } else { throw new WireException("getPageFieldset: first argument must be of type Page or Template", 1); } if (!$context->fieldgroup->get($fieldsetName . $fieldsetCloseIdentifier)) return NULL; $collecting = false; foreach ($context->fieldgroup as $field) { if ($field->name == $fieldsetName) { $collecting = true; continue; } if ($field->name == $fieldsetName . $fieldsetCloseIdentifier) { break; } if ($collecting) { if ($collectValues) { $collectedItems->set($field->name, $context->get($field->name)); } else { $collectedItems->add($field); } } } return $collectedItems; } Some extension of the above code - works with templates and pages. If thrown at pages you may choose to retrieve the values inside the fieldset as a WireData object. edit: @dragan (below) thanks for the hint! Just removed it.2 points
-
Hi PW fanatics In this post I share two of my addHookMethods for those interested. As you surely already know (if not, time to take a look at it) the Wire::addHookMethod() and the Wire::addHookProperty() API methods can be used to "breath some extra OOP" into your projects. Using addHookMethods and addHookProperty are alternatives to "Using custom page types in ProcessWire". The methods I want to share: basically the idea here is to get the URL pointing to images uploaded in the admin without writing much code in the template files. With methods like these below, it does not matter what Formatted value is set to the images, because some predefined defaults are used in all circumstances. #1 Example template file code: <?php $img_src = $latest_article->siteFeaturedImage(); ?> <img src="<?= $img_src ?>" alt="<?= $page->title ?>"> addHookMethod goes into /site/init.php <?php /* Returns URL of the original Pageimage of Article. * Image field's value can be either null (default missing image), Pageimage or Pageimages. * * @return string */ $wire->addHookMethod('Page::siteFeaturedImage', function($event) { $page = $event->object; if ($page->template != "article") { throw new WireException("Page::siteFeaturedImage() only works on 'Pages of article template', Page ID=$page is not such!"); } $article_featured = $page->getUnformatted('article_featured'); //always a Pageimages array if (count($article_featured)) { $img_url = $article_featured->first()->url; } else { $img_url = urls()->templates . "assets/img/missing-article_image.jpg"; //we show this when image is not available } $event->return = $img_url; }); ?> #2 Example template file code: <?php $img600_src = $page->siteProductImageMaxSize(600, 600, ['rotate' => 180]); ?> <img src="<?= $img600_src ?>" alt="<?= $page->title ?>"> addHookMethod goes into /site/init.php <?php /* Generates image variations for Product images. Returns URL of Pageimage. * Image field's value can be either null (default missing image), Pageimage or Pageimages. * * @param int arguments[0] Max allowed width * @param int arguments[1] Max allowed height * @param array arguments[2] See `Pageimage::size()` method for options * @return string */ $wire->addHookMethod('Page::siteProductImageMaxSize', function($event) { $page = $event->object; if ($page->template != "product") { throw new WireException("Page::siteProductImageMaxSize() only works on 'Pages of product template', Page ID=$page is not such!"); } $width = isset($event->arguments[0]) ? $event->arguments[0] : 48; //default width $height = isset($event->arguments[1]) ? $event->arguments[1] : 48; //default height $options = isset($event->arguments[2]) ? $event->arguments[2] : $options = array(); //default empty options $product_image = $page->getUnformatted('product_image'); //always a Pageimages array if (count($product_image)) { $img_url = $product_image->first()->maxSize($width, $height, $options)->url; } else { $img_url = urls()->templates . "assets/img/product-missing-image.jpg"; //we show this when image is not available } $event->return = $img_url; }); ?> BTW, you can find more examples here: How can I add a new method via a hook? Working with custom utility hooks Adding array_chunk support to WireArray addHookProperty() versus addHookMethod() Have a nice weekend!1 point
-
This week we've got more to tell (and show) you about our upcoming page export/import feature, along with several screenshots of the progress: https://processwire.com/blog/posts/processwire-3.0.68-and-more-on-page-export-import/1 point
-
Hi all. For a while now been wondering how many would be interested in a backend and frontend shop catalogue built on top of PadLoper? I've previously spoken to @apeisa about this and his take is that there are no plans to develop PadLoper in this direction but he's happy to support such efforts. The gist of the backend shop catalogue is to provide one place (think ProcessModule) where you can manage your PadLoper products - add, edit, delete, track sales, etc without having to set up the underlying structure yourself. The frontend would be like a shop/webstore profile, a frontend cart basically, that's customisable. The shop would be 100% powered by PadLoper. This means that to use the 'shop catalogue' would require that PadLoper is installed. These are just loose ideas at the moment for a pro module. This might or might not see the light of day depending on feedback. Anyway, would love to hear thoughts, thanks.1 point
-
Hi @Klenkes - I decided to go with #2 - now BCE will only apply the "purify" sanitizer if the field that is being populated/updated has the HTMLPurifier enabled. Could you please test at your end to make sure it works as expected? Thanks!1 point
-
Just a quick note: remove the hints in the function, otherwise it won't work: function getFieldsetOf($context, $fieldsetName, $collectValues = false, $fieldsetCloseIdentifier = '_END'); // this will work function getFieldsetOf($context, String $fieldsetName, bool $collectValues = false, $fieldsetCloseIdentifier = '_END'); // this won't at least not with the latest PW dev on PHP 7.0.9 example function call: $fieldSet_import = getFieldsetOf($templates->get('project'), 'import_only', false, $fieldsetCloseIdentifier = '_END');1 point
-
I never used Blade, so I don't even know if that's an option, but can you tell Blade to not create that cache file in the first place? If that's not possible, try to disable cache in your template(s). Alternative multilang approaches are described here: And then there's also the recently added functional fields (never used it myself so far): https://processwire.com/blog/posts/functional-fields/1 point
-
This is what I was after. $testimonials = $pages->get(1019)->testimonials->find("limit=5, sort=random"); Credit to @adrian:1 point
-
For modules you could use the module toolkit module. Though it would be nice to have one place to go to export everything.1 point
-
That explains a lot For the sites I migrate to PW option 1 would me my choice, because importing the content is the first priority and editing the content comes later. Nobody wants to sift through a few hundred pages to make it all like it was. In my case editors are skilled, trusted and would be fired if they do monkeybusiness with the HTML. ...but then again... option 2 would work as well since I already deactivated all the purifier options for the fields anyway. For now I will go with the dirty fix1 point
-
Hey @bernhard - I spent quite a bit of time looking into this the other day with no success. It turns out it's not just hooks inside ready.php - it seems like ready.php is never called at all from the Tracy console panel. I will investigate further, but so far a bit of a mystery. I thought perhaps it was an issue with ajax calls (which the console panel uses), but a normal ajax call results in ready.php being called, so really not sure at the moment. I'll see what I can figure out. Cheers, Adrian1 point
-
Me again... I imported a few hundred pages to more than 30 parents and almost everthing is fine. Then I noticed that all custom ids and classes in my imported textareas were filtered out during save, even with deactivated ACF and HTML Purifier(in textareas settings) Pasting in the same HTML in source mode afterwards leaves the custum stuff alone. So it works. I don't even know wether it's a BCE issue or with Profields textareas? This problem seems familiar but I can't remember...1 point
-
@Robin S Thanks for your work! I will gladly merge a pull request to make this module PW3 compatible1 point
-
@clsource: sorry for the delay. Weekly.pw RSS feed should now work as expected1 point
-
@clsource You must be the only person on the planet who reads these RSS feeds Nevertheless, this issue should be fixed, of course.1 point
-
$pages->get('/') just returns the ID of the home page. Try $pages->get('/')->url1 point