Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/17/2017 in all areas

  1. @Macrura, your Micro Contexts idea is clever. The approach you are taking here (effectively a single template where fields may be shown/hidden and labels/descriptions changed depending on context) is in fact exactly what is done in Repeater Matrix. Every matrix item (page) actually has the same fields, but the field visibility and labels etc are controlled by the matrix type context. So that got me thinking that all that is needed to do something similar with Repeater Matrix is to add some control that allows the user to change the matrix type of an existing Repeater Matrix item. The advantages over the Micro Contexts approach are: You don't have multiple templates that must be kept in sync if new fields are added - if you add a new field to any given matrix type it is added to the single Repeater Matrix field template. You can do all your field overrides (visibility, width, label, description, notes) from a single screen (the Repeater Matrix field settings). So as a result it's quicker to set up and easier to maintain. I have put in a request to Ryan to add such a control, but I had a play around and managed to get something working with a couple of hooks. To use this... Create a new text field named 'block_type' (best to create a dedicated field for the purpose). Set the field visibility to 'Closed' (to keep it discreet). In your Repeater Matrix field settings, add the block_type field as the first field in each matrix type. Add the hooks below to /site/ready.php... // Change the block_type inputfield to a matrix type select $wire->addHookAfter('InputfieldText::render', function(HookEvent $event) { $inputfield = $event->object; $field = $inputfield->hasField; if(!$field || $field->name !== 'block_type') return; if($inputfield->name === 'block_type') return; // in case field is not being rendered inside repeater inputfield $rpage_id = str_replace('block_type_repeater', '', $inputfield->name); $rpage = $this->pages->get($rpage_id); if(!$rpage->id) return; // just in case $matrix_field_name = substr($rpage->template->name, 9); $matrix_field = $this->fields->get($matrix_field_name); $raw_matrix_types = $matrix_field->type->getMatrixTypes($matrix_field); $matrix_types = []; foreach($raw_matrix_types as $key => $value) { $label = $matrix_field->get("matrix{$value}_label"); $matrix_types[$value] = $label ?: $key; } $if = $this->modules->get('InputfieldSelect'); $if->name = $inputfield->name; $if->label = $inputfield->label; $if->required = true; foreach($matrix_types as $key => $value) { $if->addOption($key, $value); } $if->value = $rpage->repeater_matrix_type; $event->return = $if->render(); }); // Change the matrix type on saveReady $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); if(!$page instanceof RepeaterMatrixPage || $page->block_type === null) return; if($page->isChanged('block_type')) $page->setMatrixType($page->block_type); }); If you wanted to remove certain Repeater Matrix inputfield controls then you would use a hook/module as discussed in earlier posts in this thread.
    4 points
  2. @ryan, stuff like this is super-interesting to us aspiring devs and I for one would give my right arm to take a peek at your code and see how an expert approaches these things. It would be a really great learning opportunity. In general, would your client contracts allow you to share snippets of project code with the community? Would you be comfortable doing that? (not expecting you to reveal all your secrets!) Not in any way that would require you to invest time in making things plug-and-play or offering support for them - just dropping some interesting bits as Gists on Github. A possibility?
    4 points
  3. This week we take a closer look at the useful new page export/import functions that we’re currently building into the core: https://processwire.com/blog/posts/a-look-at-upcoming-page-export-import-functions/
    2 points
  4. cool, ok thanks – will accept/merge asap.
    2 points
  5. thank you macrura but the hash feature is not working in panels as i stated above anyhow - one click more than needed is ok for my client. thats nothing with priority so far. just wanted to throw in this idea and i'm happy if this finds it's way into this module. if not sooner, than later. totally fine for me i'm sure it would not be a big addition t edit: added a PR (quickfix) on github to support query strings like /?docs=my-single-docs-page taking the pagename of the docs page as parameter
    2 points
  6. thanks for mentioning me here mr-fan but i don't think my module would be a good solution here. its only intended to display data (like lister and listerpro do) but with a lot more customization options (like different renderers, eg rendering timestamps as dd.mm.yyyy but sorting based on the unix integer etc) i recently worked with chart.js (pulling data from my datatables module to have live filtering and sorting and see details that the chart hides because it shows only accumulated data). its very easy to use! you only have to provide a data array and set the options and thats it. some snippets may help to get an idea: var soll = { label: 'Controlling', data: getDataKum(goals[chartname]), borderColor: 'black', borderWidth: 1, borderDash: [10, 5, 2, 5], backgroundColor: 'rgba(0,0,0,0)', }; var ist = { label: 'IST', data: getDataKum(getIstData(chartname)), borderColor: 'green', borderWidth: 1, backgroundColor: 'rgba(0,0,0,0)', }; // chart data var data = { labels: ['jan', 'feb', '...'], datasets: [soll, ist], } // draw chart // this is inside a loop to draw 4 charts with the same settings // [...] $el = $('#'+chartname+'_chart'); charts[chartname] = initChart( $el, data ); /** * chart initialisation draw */ var initChart = function($el, data) { var myChart = new Chart($el, { type: 'line', data: data, options: { scales: { yAxes: [{ ticks: { beginAtZero: true } }] }, elements: { line: { tension: 0 } }, tooltips: { mode: 'index' }, }, }); return myChart; } getDataKum() just returns an array of values. you could also just provide a static array via $config->js, for example: // php $config->js('mysampledata', [1, 2, 3]); // js var myChart = new Chart($el, { type: 'line', data: ProcessWire.config.mysampledata, [...] }); happy charting
    2 points
  7. I think get() always returns a single page. Have you tried $pages->find("id=1|2|3"); which will return a PageArray.
    2 points
  8. 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 :
    2 points
  9. Adds a Service Worker to your Processwire site which can be customised. The service worker script itself is heavily based on Jeremy Keith’s work – thank you Jeremy! More information: https://github.com/johannesdachsel/processwire-serviceworker
    1 point
  10. Hi, Did you check where session files are actually saved? Eg.: https://stackoverflow.com/questions/4927850/location-for-session-files-in-apache-php
    1 point
  11. I've just extended FieldtypeTime and InputFieldTime by support for blank values Failed to add a push request to https://github.com/netcarver/PW-FieldtypeTime, so please find my patch attached ... Works fine at me. PW-FieldtypeTime-Empty-times.patch
    1 point
  12. There are many on this forum who would like to help you. Could you provide some additional information regarding your ProcessWire installation, third-party modules installed and any other special setups/configurations you may have made?
    1 point
  13. I've been a bit like the proverbial plumber with a leaky tap, with a rather ugly site myself, but I've had a period recently with very little work, so I thought it might be time to give my own site Create IT a refresh. I've got more work to do on it, but it's enough of a step up that I'm not totally embarrassed by it now. My site was running on a CMS I've developed myself since 1999 using an obscure language Mivascript, that was actually quite popular at the time, and my first exposure to a server scripting language. To put that in context, the first version of Wordpress only came out in 2003, and to be honest my code looks quite messy in the light of modern programming best practice. I've decided I'd rather focus on adding functionality and content than maintaining an entire CMS myself, and I love Processwire for its speed and flexibility of development. I had to import my existing content which was in a mySQL database. Having written the system myself, I knew the data structure well, so the issue was how to replicate the functionality. My old CMS was started before the days of SEO and security got a great deal of attention so I had urls like index.mvc?article=6. I had to come up with a safe way to redirect these to knew Processwire URLS. The Jumplinks module came to the rescue there, as when I'd imported my data, I'd already imported the old page ids into a field in processwire, so it ended up being pretty easy to provide automatic redirects from the old URLs with just a single jumplink using a selector. The other thing I wanted to do was use Bootstrap, but customise it without creating a mess of overrides. AIOM+ came to the rescue here, with its built in ability to compile LESS files. Rather than messing around with any third party LESS compiler, I could just put the Bootstrap source directly into my project and include the LESS files directly. Processwire never fails to impress how quickly and efficiently it enables often quite complex things to be done.
    1 point
  14. Thanks for spotting. It worked fine on my WAMP development server, but of course I didn't have the .mvc file there. I've renamed it, and tested for an actual URL from the old site /index.mvc?ArticleID=181 and it's working as it should. With regard to the CSS, I was trying to follow best practice according to Google Pagespeed Insights, but perhaps I'm being a bit overly picky trying to get a good Pagespeed rating.
    1 point
  15. Hi, As far as I know, since ProcessWire 3.0.29 we have RewriteRule "(^|/)\.(?!well-known)" - [F] there by default. See: https://processwire.com/blog/posts/pw-3.0.29/#summary-of-added-pull-requests
    1 point
  16. Did you try the http://modules.processwire.com/modules/fieldtype-secure-file/ module?
    1 point
  17. Hmm i forgot a alpha module from @bernhard that works with more complex data in backend and frontend...
    1 point
  18. Pushover looks pretty cool. I’m currently implementing realtime functions in a PW project using http://pusher.com, totally recommend it!
    1 point
  19. And there you have it, the easiest multilanguage website in the history of CMSs
    1 point
  20. Now also powered by ProCache - thanks a lot for your help with our quirky hosting environment Ryan! The work you put in on PW, and to help us get it to work to the fullest of its fantastic potential is nothing short of amazing! I would urge everyone that haven't already done so, to try this plugin, and in minutes release the speed potential of the sites we put so much time and effort into creating.
    1 point
  21. With template files you generally have a documented set of API variables ($page, $pages, $user, etc.), and this is what the set() methods of TemplateFile are geared towards. On the other hand, when passing variables into a $page->render(), variables passed in may be unknown/undocumented to the template file, and will be installation-specific, since PW doesn't pass in API variables that way. By having them in a known array ($options), you have a way of inspecting them, or at least knowing where they will be. Otherwise, the template file would have no means of self discovery for these things. It decreases the unknowns, increases the portability, and introduces an appropriate level of separation from the system API variables. On the other hand, this is largely theoretical… I've never had the need to pass in variables to template files in this manner, so am mainly just trying to accommodate the needs brought up in this thread.
    1 point
×
×
  • Create New...