-
Posts
11,088 -
Joined
-
Last visited
-
Days Won
365
Everything posted by adrian
-
#7 of 50: http://dailycodex.com/top-content-management-systems/ http://www.queness.com/post/14579/6-lightweight-flexible-php-cms/page/1 http://preludi.fi/blog/processwire-julkaisujarjestelma-6-syyta-valintaan
-
Processwire 3 - using the API in Open Cart - wee hitch
adrian replied to icreation's topic in API & Templates
Nice one bernhard - I totally missed the line in the OP noting that PW was being bootstrapped -
Nice one Jan Romero - I hadn't seen the use of the Selectors class and PageFinder like that. Putting it all together: $selectors = new Selectors("template=basic-page"); $pagefinder = new PageFinder(); $sql = $pagefinder->getQuery($selectors->getArray(), array("returnVerbose" => false))->getQuery(); $result = $database->query("SELECT SUM(data) AS sum_amount FROM field_amount WHERE pages_id IN ($sql)"); $sum = $result->fetch(PDO::FETCH_COLUMN); echo $sum; Note that I had an SQL error regarding "SQL_CALC_FOUND_ROWS" when I included a limit in the selector. If I removed the SQL_CALC_FOUND_ROWS then it complained of not allowing limit in IN. Remove the limit from the selector and things work just fine. Also, note that you need to specify "returnVerbose" => false - otherwise you get a php NOTICE: https://github.com/ryancramerdesign/ProcessWire/issues/1734
-
Not necessarily the answer you are looking for, but searching on Github is often very enlightening: https://github.com/ryancramerdesign/ProcessWire/search?utf8=%E2%9C%93&q=%22%24field-%3Eattr%22
-
If you didn't have so many pages I would say go for something like this where you populate the pageids from your selector in the IN clause. SELECT SUM(data) AS sum FROM `field_amount` WHERE pages_id IN ( 1234, 2412, 1234 ) But with 1 million page ids in your "IN", that's not going to work What about this: SELECT SUM(data) AS sum FROM `field_amount` INNER JOIN `pages` ON `field_amount`.`pages_id` = `pages`.`id` WHERE `pages`.`templates_id` = 29 The problem with this is that you need to reproduce your initial pages selector - in my example I am just limiting to a template. Do you think you could make this work? What is your actual selector?
-
Processwire 3 - using the API in Open Cart - wee hitch
adrian replied to icreation's topic in API & Templates
Sounds like output formatting may be off, or you have changed the Formatted Value for the field - what is that set at? Also, try this just before outputting the image and let me know what it returns. echo $page->of(); -
Processwire 3 - using the API in Open Cart - wee hitch
adrian replied to icreation's topic in API & Templates
Looks like the homeboximage field is not set to "1" for the Max Files Allowed setting. Either change that, or do: echo $homebox->homeboximage->first()->url; -
Hi everyone, Thanks to a request from @Ralf, this module now also works on the front-end. If you have setup your own login form and profile editing forms you can enable this for the front-end and specify a URL to redirect to for the user to change their password.
-
This tutorial from soma might also be useful: https://processwire.com/talk/topic/4602-flexible-downloads-using-pages/ Also, if you're working with SVG files, these two modules might be of interest: http://modules.processwire.com/modules/image-rasterizer/ http://modules.processwire.com/modules/file-validator-svg-sanitizer/
-
Pagination and filter pages with pages->find doesnt work properly
adrian replied to Juergen's topic in General Support
I think what you are looking for is whitelist: $input->whitelist($name, $value) Read about it under the getVars section on this page: https://processwire.com/api/modules/markup-pager-nav/ -
New public method: TD::templateVars() templateVars() tv() Basically what this does is strip any system PW variables and returns just those that you have defined in your template file. It replicates what is output on the "Variables" panel, but lets you dump, barDump, fireLog, or log at whatever points you want throughout the execution of your template file script. Obviously if you are only interested in the changes to one variable there is no point in using this, but if you want to see how they all change, this is a nice shortcut. It is really only designed to work with PHP's get_defined_vars() Here's an example output via barDump: bd() $i=0; $x=10; bd(tv(get_defined_vars()), 'breakpoint one'); $i++; $x--; bd(tv(get_defined_vars()), 'breakpoint two'); This results in: Without tv() in there it would include all PW variables/objects and it would be difficult to see the variables you are interested in. Note that the templateVars() and tv() shortcuts/aliases may need to be turned on in the config settings if you are upgrading.
-
Small update that enhances links from the PW Info panel Summary section - now you can have shortcuts to either view (page name) or edit (page id) each of the linked pages that are related to the current page. The children item now has: an "open tree" link (opens this page in the page tree expanded to show all children) an "edit" link (opens this page to the Children tab, which is particularly useful if you have Batch Child Editor installed). The template filename in the Template Info section uses the defined editor protocol handler to open the file directly in your code editor. Hopefully you'll all find these nice little time/click savers And page edit and template file edit buttons are also in the footer of this panel for instant access:
-
Why did you have to comment those things out?
-
Hi Esther, I have just been acquainting myself with Unbounce. It doesn't look like they offer a way to export their pages as HTML (https://community.unbounce.com/unbounce/topics/can_i_put_the_html_from_unbounce_onto_my_website). Sure you could view source, or use a browser downloader so that it grabs all javascript and css files as well, but it will be a but fiddly. It sounds like the correct way to go is to use CNAME records to handle serving of your landing pages that are hosted on the unbounce servers so they appear as part of your site. I'd still need to do a little more research to figure out exactly what is needed and what the options are, but it might be best to just go with what they recommend. Do you know what approach your web guy normally uses when hosting/serving unbounce pages.
-
The init.php file needs to be: /site/init.php Have a read about this here: https://processwire.com/blog/posts/processwire-2.6.7-core-updates-and-more/#new-core-files-for-site-hooks PS - the hook would also work in /site/templates/admin if you only want to prevent the view link in the admin. If you want to prevent separate viewing on the front-end of the site as well, then it should be in /site/init.php
-
Another approach would be a hook in your init.php $this->addHookAfter('Page::viewable', function($event) { if(strpos($event->object->template, 'section-') !== false) { $event->return = false; } });
-
How to get array of page ids by selector if there are 10000+ pages?
adrian replied to valan's topic in API & Templates
I thought I remembered there being something like that, but couldn't find it. Thanks for the reminder! PS And of course findIDs makes much more sense than my suggest getIds -
How to get array of page ids by selector if there are 10000+ pages?
adrian replied to valan's topic in API & Templates
A "getIds" option might be nice. $pages->find($selector, array('getIds' => true)); It would be in a similar vane to: $pages->getByPath('/path/to/page', array('getID' => true)); but would obviously return an array of IDs, rather than a single one like with getByPath. Or maybe: $pages->getIds($selector); which has the same feel as: $pages->count($selector); -
I haven't read through, but since this forum is scheduled to be updated to IPBoard 4.x fairly soon, maybe there are some new options available: https://community.invisionpower.com/blogs/entry/9639-40-follow-system/
-
Just wanted to post here to note that the issue @planmacher had has been fixed - it was actually affecting the role name and custom php code options.
-
ProcessWire doesn't dictate any of the frontend code at all - you can write whatever HTML, CSS, and Javascript you want and simply add in the content from the PW database wherever you need. So, the answer is definitely yes, but you still may want to take the content from the landing page and make that editable by the Processwire backend, although this certainly isn't necessary. If it's the homepage of the site, then you will be putting the HTML they provide into: /site/templates/home.php - if there is no need for any php or calls for field data from the PW database, you can leave off the opening php tag completely. Hope that helps.
-
Glad to hear it's working for you - hopefully this new approach will work in all scenarios. As for debugging debug.innerHTML - I haven't had to debug it yet - it's mostly generated by Tracy anyway. Being a JS variable, there isn't really an easy way of making it multiline without concatenation, which really isn't worth the trouble in this case. I am looking forward to Template Literals in ES6 though - we'll finally have real multiline variables for JS. But, back to your question, - if you do need to debug code like that you can use the regex find & replace option in your editor to replace \\n with \n and \\t with \t and it will be fully formatted. In Sublime Text (in case you use that), click the asterisk in the find and replace box - super easy!
-
@matjazp - just letting you know that the latest version includes the fix for your problem. Could you please let me know if it works for you?
-
Thanks @matjazp - that helped - I had forgotten to consider text after the last closing php tag. I have a fix that is working here. I have something else I am working on with Tracy right now so I'll commit both things fairly soon.
-
Is your site available on the web somewhere, or just on your local dev setup? If you'd be willing to PM login details, I'd be happy to take a look.