-
Posts
2,766 -
Joined
-
Last visited
-
Days Won
40
Everything posted by Macrura
-
Micro Contexts (aka field value contexts) Change any context-enabled setting in your page editor/template based on the value of a page reference field. Why use this? Say you have a template that is controlling some generic part of your website, like a section on the homepage, a widget, or an item in a media library. If you are using the various fields on this template in different ways depending on an option (page select) such as 'widget_type', 'media_type', etc, you can hot-switch the template context based on the field's value. Why not use template, like just change the template? Unfortunately, most of my clients would probably break down in tears if i tried to explain what a template is, or how to change it. This also allows you to have better more relevant labels, descriptions and notes based on any page ref field value on your template, as well as be able to show/hide fields based on that value, or even move fields around to make some more prominent or visible. How to use this 1.) Create a new template: 1a) Use the following name structure: mc-[field_name]-[field_value]-[any_memo_here] where [field_name] is the field that will control the micro context, and the [field_value] is the required value (page id) that the controller field must equal/have in order to trigger the virtual template context. The last part of the template name should be used for the page name, or some memo to make it easier to know from the templates list what field value will trigger the micro context, since the template name does require the ID value of the field, not the name. 1b) Make sure to specify the template you are contextualizing under "Duplicate fields used by another template" before clicking save! 1c) Edit your field settings for this template, for when your fieldname=value as specified in the template name (labels, descriptions, notes, visibility, field order etc.) 2.) Place this code in your ready.php file: wire()->addHookAfter('ProcessPageEdit::loadPage', null, function (HookEvent $e) { $page = $e->return; $mcPlates = $this->wire('templates')->find("name^=mc-"); if(!count($mcPlates)) return; foreach($mcPlates as $mcPlate) { $nameParts = explode('-', $mcPlate->name); // expected format: mc-[field_name]-[page-id]-[anything-you-want-here] $mc_field = $nameParts[1]; // the field controlling the micro context $mc_value = $nameParts[2]; // page id has to be the 3rd part of the template name $controllerField = $page->fields->get($mc_field); //if we find a matching controller field from the template name... if($controllerField) { $f_value = $page->get($controllerField->name); $proceed = false; if( ($f_value instanceof PageArray) || ($f_value instanceof Page) ) $proceed = true; // this only works with page reference fields. if(!$proceed) continue; // the page corresponding to the required value (page id) specified in the mc template name, to change micro context $mc_page = wire('pages')->get((int) $mc_value); // if the value specified in the mc template name matches the current value of the page reference field, change the // fieldgroup context $proceed = false; if( $f_value instanceof PageArray && $f_value->has($mc_page) ) $proceed = true; if( $f_value instanceof Page && $f_value == $mc_page ) $proceed = true; if($proceed) { $tName = $mcPlate->name; $mc_template = wire('templates')->find("name=$tName")->first(); if($mc_template) { $mc_fieldgroup = $mc_template->fieldgroup; $page->template->fieldgroup = $mc_fieldgroup; } } } } }); Caveats This probably needs more work to be fully usable, and may need more bullet proofing in terms of checking for valid template name, etc. You can only have this work with 1 page reference field per template. This has been tested and is being used on at least 2 live sites, but caution should be used, and the functionality should be tested before using on a live site. Screenshots: 1) a default widget with no field value context enabled fields 2.) A field value context enabled edit page for the 'Widget Type', the template controlling this is now 'mc-widget_type-1054-text', but the template of the page stays as 'widget'; only the fieldgroup context is changed when the page is loaded to get the contextual settings: 3.) the context for when the page reference field called 'widget_type' has the value of 1150, which is a video widget type (template name is 'mc-widget_type-1150-video'). Convenient Module edition coming soon!
-
I will try and test on my local environment, but probably can't post back on this until Sunday or Monday
-
Have you tried a different prefix?
-
I think you need to use pagefileSecure: $config->pagefileSecure bool When used, files in /site/assets/files/ will be protected with the same access as the page. Routines files through a passthrough script.
-
I noticed that if a table is marked as 'crashed', the process module won't load, e.g. you get a "process returned no content", instead of the usual interface. We have had some server issues with Site5 hosting that has caused tables to randomly crash and only way to fix is from phpMyAdmin, but if we could use ProcessDiagnostics to repair the table(s), that would save a step..
-
I Love The SkyScraper Demo but can I installed it from cpanel?
Macrura replied to Dee's topic in Getting Started
I would recommend learning how to install it manually. AFAIK profiles are installed when you install the system itself, because a profile is a complete, self-dependent collection of data, templates, modules, functions and a front end that all work together. In terms of the cPanel automated backups, perhaps you can still have automated backups, even if you don't install PW using the cPanel installer. In terms of upgrades, i wouldn't recommend any sort of automated upgrades, because with any upgrade you always risk something not working, so you'll want to use a stable version and then don't upgrade it unless absolutely necessary. ProcessWire is not like other CMS that have constant updates and security fixes. Sites run fine for many years on a stable version, and only need upgrading when you requires some feature of a newer version. In the case of upgrading, the process is such that you can fairly easily roll back any upgrade you make (to modules and core). For example if you upgrade a module using the updates module, then the old one gets renamed with a prefix dot. If something goes wrong with because of that particular module upgrade, then you can switch out the old one, but you need to do it using FTP. In terms of playing with the Skyscrapers Demo, it is certainly worth checking out, both the structure in the admin, but more importantly the template files where all of the PHP code is to make the magic happen. -
I'm not totally sure if Sharrre still works – it hasn't been updated since 2012 and I think it stopped working on some of my sites so I replaced the sharing buttons and used the MarkupSocialShare; I would double check that everything works and you are able to get the values from Facebook...
-
ckeditor extra allowed content not work properly
Macrura replied to adrianmak's topic in General Support
or if you need to have inline icons (within the editor), you could use a hanna code to convert the hanna tag into an icon. -
Module Visual Page Selector (commercial page picker module for ProcessWire)
Macrura replied to kongondo's topic in Modules/Plugins
ok thanks, i will send a message.... -
I thought we already had seeds... http://cheatsheet.processwire.com/pagearray-wirearray/getting-items/findrandomtimed-n/ http://processwire.com/api/ref/wire-array/find-random-timed/ though not sure if this will work for your use scenario...
-
It could be possibly tricky to have the reset admin password on the admin template, since you cannot predict who will access that... The tip is useful though, and would be probably too complicated for the scope of that article to explain about putting it into some more obscure template (like a console or tools/api); $users->get('admin'); maybe needs to be $users->get('name-of-superuser'); // change this to the actual 'name' of the user
-
About Standard Theme Processwire: where is html file?
Macrura replied to franciccio-ITALIANO's topic in General Support
you would be writing php code to communicate with the PW api, to get your dynamic content from the CMS. In reference to the $config->urls->templates, you can take a look at the default _main.php to see how that is being used to reference the themes folder, when you reference an asset (css or js file) that is stored within your templates folder. -
I would just do a normal page for news ; your sidebar and main content would be separate things, and then your news template shows the $page->body, this way the news pages are indexable, and bookmarkable. the links need to links to the ->url parameter,so if you are foreaching the news items on the sidebar as $item, then the href is $item->url;
-
About Standard Theme Processwire: where is html file?
Macrura replied to franciccio-ITALIANO's topic in General Support
I would just say, it's no small thing – adapting a CSS theme to be used in processwire requires a decent knowledge of how to use the API, as well as some fairly good experience with HTML and PHP. I can get a basic HTML 'theme' into a simple PW site in around 3-5 hrs, depending on the complexity, and that is using a lot of helper modules and functions that I developed over the years. It depends on the content of the site, how many templates you have and the types of fields you are using. For a 1 page site, it should be pretty simple, you just need to replace the contents of the _main.php file with the content of the html file and then update all of the paths to the assets, using for example a call to the $config variable for the templates folder (e.g. $config->urls->templates . "styles/my-style.css";) -
you should be able to paginate any PageArray https://processwire.com/api/modules/markup-pager-nav/
-
comments: 1) You might want to consider using pages instead of repeater for news items (repeaters are not really meant for infinitely scaling content types) 2) Sounds like you want to use ajax to change the content of the news article that was clicked on, on the left side? - maybe take a look at this: http://barbajs.org/
-
About Standard Theme Processwire: where is html file?
Macrura replied to franciccio-ITALIANO's topic in General Support
They are not, the templates are PHP files. You need to look in /site/templates/ Yes But if you use the wireRender pattern, then you can create pure html views, still .php files, but those can be placed into a $content variable for delayed output. -
it would be cool if the classes were a field in the module config, so you could add or change them
-
Module Visual Page Selector (commercial page picker module for ProcessWire)
Macrura replied to kongondo's topic in Modules/Plugins
Hi Kongondo, i'm looking for a popup page selector, that would show the pages in a lister – but in my case sometimes no image is needed, only the list - is that something that VPS can do, or could it be something made configurable for the module; Out of all of the various page pickers, one that i seem to be in need of is a lister style popup, which could be very useful where you have to select a page, but need to see some columns to know what you are picking, and the ability to sort, and filter the selectable pages... -
looks like the gallery detail pages are missing title tag, for example: https://rockpoolpainting.com.au/gallery/cooranbong/
-
i don't believe you can PHP 'include' an html file, that's what my example shows, e.g. if you include then you change it to .php, or .inc. I don't know what you mean about 'form field', to confirm your question, there is no such field.
-
the problem is that you have an array, but the items in the array are \ProcessWire\Page objects, so those can't directly map to a json encode. you probably need to cycle through the pages you want and create the array manually. Alternately you could have a look at the GraphQL module, which i think some devs are using to get json data to the frontend.
-
on the page where you want to output the form, you can just conditionally load that markup from a .php, .inc, or .html file, depending on what your needs are. for example: <?php if($page->name == 'my-special-page') { // html version $form = file_get_contents($config->paths->templates . 'forms/my-form.html'); // OR wireRender $form = wireRenderFile($config->paths->templates . 'forms/my-form.php'); echo $form; // or include($config->paths->templates . 'forms/my-form.php'); }
-
That would be great - i will probably need a few weeks to sort out some issues; the theme module works by using a new WireData within global $config to store everything, and it gets initialized manually; i am trying to decide about this, and whether it should just create it's own api variable; if using $config, then it makes it easier for submodules to intercommunicate, because there is sitting the $config and then a module can check to see if there is a property in there to use; also with the theme's headAssets method, it will be better once the minification engine can be selected, right now it is hardcoded to use ProCache, but plans are in place to make it selectable between ProCache, AIOM+, or none. Another thing i have to implement is a way to register your injectable areas; right now the module init defines those, but there probably needs to be a hook or method where you can register the areas in your theme, like wp add_action..
-
most of the functions were previously in helper files and called procedurally, there is nothing too complicated about any of the functions; i just finally figured it was time to put them all into a module so that i could have a config screen and not worry about field naming between sites, because the config screen lets the module's methods be field-agnostic (for example in the blog engine, you would tell it what field is used for date, what the posts index page is, post index template etc)... I will probably put it on GitHub once it has been tested more in some varied environments. You can find a lot of these types of functions in other modules, depending on your specific needs, or don't even use a module for it, a lot of developers just put each thing into a partial and then include or wireRenderFile them all in the main template. the events engine that i'm using is just helpers for front end, so primarily deals with date formatting, handling feeds, URL segments for things like archive or month/year based results (/calendar/year/2016/), categories and tags if those are used, media (images/audio/video), related events, and schema.. recurring events are usually handled with either a multiplier for a date field, a table, or a page table, depending on the needs of the site. The Elliott Carter events listing uses a page table for recurring events because each event recurrence can actually be in a different location (for example a tour).