Leaderboard
Popular Content
Showing content with the highest reputation on 01/20/2017 in all areas
-
This week's version of ProcessWire expands upon our markup regions support introduced last week, and also contains various minor fixes and tweaks. In addition, it adds a $urls API variable which is simply a shortcut to $config->urls. But since this is so commonly called upon, the shortcut can be useful in reducing verbosity in some template files. Meaning, if you want the URL to /site/templates/, you can now use the shorter $urls->templates rather than $config->urls->templates, if you'd like. This also adds consistency with our recently introduced urls() function that's part of the optional Functions API. https://processwire.com/blog/posts/processwire-3.0.50-core-updates/11 points
-
@Robin S It wasn't my intend to talk that much about separation of concerns at all, but about the fact, that people new to ProcessWire need a system which is first and foremost clear to grasp. This new region syntax is in my opinion the opposite. It might work for the tutorial type of situations, but I'm not sure it'll hold true for much beyond that. My biggest issue with it is that it's keeping it's state without any clear indication of what's happening. Someone who didn't read the docs on this feature or maybe just skimmed it lazily won't be able to tell why things happen as they happen. And that's probably the average guy or gal out there trying out ProcessWire for the first time; clueless of any of the magic id matching happening in the markup. The older function-based implementation of the regions api is way more explicit in telling even the clueless reader of the code that stuff is being placed in some kind of regions, which are later printed in the wrapping markup. My addition of "separation of concerns" as part of an educational piece on templating was just for it's own sake: education. I see lot's of code examples around the forums, which are just a mess of business logic mixed with view logic mixed with html markup. Such code is a nightmare if the client comes around and asks you to change some things here and there. Even better if things should later be used in multiple different places. It would be a shame to leave those issues out when discussing the differences between templating strategies in processwire.3 points
-
I'd say go for it! Not only do I wish you success in your endeavour, but I am hopeful that this will also give ProcessWire some good exposure .3 points
-
Yes and no Maybe this time you could keep it a bit more organized like this 4 part tutorial: http://blog.mauriziobonani.com/processwire-basic-website-workflow-part-1/ as opposed to the journal style of this thread. If you take notes first and later on write the parts of a series one-by-one, then it can be more "tutorial like".2 points
-
When deciding whether or not to use a parent-child structure to create a relationship, the questions I ask are: 1. Is this relationship a primary (very important) relationship? 2. Do I want the relationship to be revealed in the page URL? (Note that other types of relationship may still be represented in a URL via the URL Segments feature) 3. Is the relationship exclusive? (i.e. may the child only belong to a single category/parent - you want to avoid a situation where the same page would appear under more than one parent). If the answer to any of these is "no" then I use a Page field for the relationship rather than a parent-child structure.2 points
-
If you just want a notification that a page is currently being edited by another user (like the default behaviour of Page Edit Soft Lock) then the optional core System Notifications module also has that feature. But if you want a "hard lock" option then I think Page Edit Soft Lock is the only option currently.2 points
-
Technically my rest helper is just some functions that I used when creating simple Rest backend with ProcessWire. So is nothing too fancy, just what I needed. See the voxgram repo that used the Rest Helper . The magic with PW is that you can integrate it with more sophisticated tools like Symphony components using composer if you want to. May be I should write a simple tutorial using Rest and PW?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
-
this is how you set a field on the $u page, if the field exists you have to save the page after. To set a session variable use https://processwire.com/api/ref/session/set/ and to get it use https://processwire.com/api/ref/session/get/ https://processwire.com/api/ref/ Edit: users are pages too.2 points
-
2 points
-
<?php $subpages = $pages->find("has_parent=/deals/, template=subpage, sort=-publish_date"); foreach($subpages as $subpage): ?> <?php echo $subpage->deals_category?> <?php endforeach; ?>2 points
-
@gmclelland and everyone. Latest version takes care of the hook priority issue and adds a new feature to the new hide/show toggle button. Now if you have it hidden and it detects an error it will force it to display. Once you fix the error, it will go back to being hidden again. I think this is a nice compromise for those who don't like having the debug bar visible all the time, but don't want to miss any reported notices/warnings. Please let me know if you notice any problems with this change.2 points
-
Hey, everyone. As far as NowKnow project is about to be finished soon and presented to the team, I decided that it would be great to invite my 12 years old daughter to work with me on another theme which I found and am willing to share the transitioning from pure mobile friendly HTML to PW theme. This time I chose a theme that has a few different contents in it but should be pretty simple once the bits and pieces of NowKnow are in place. Once you try to do a theme, the rest is easy and you are actually starting to improve the code -> enjoy the work. As far as my daughter have some basic HTML & Jquery coding skills, it is not yet clear who will be the student What is more important is to provide both of us some creative time and to be able to share the result (even if it might need some polishing etc.) As a theme, I selected a theme from ShapeBootstrap.net called Corlate. The source is absolutely free so feel free to grab it if needed and assist in the development with what you can. Unfortunately, I can't tell exactly when will we be starting as I still need to implement tags/keywords, comments and eventually add a possibility to upload files other than images as it would be beneficial for the team to be able to attach any already premade files into the new site. As far as my important job tasks are almost complete and I will have some more spare time after work, we should start soon. Should you think that there is a more interesting theme to work on (with more advanced features etc.) that is free to use and share with the rest, feel free to let me know and we will see what can be done2 points
-
$pages->get() will always get you ONE page only. In your case, it gets you the first child of $store, i.e. Page A. This is because Page A, via sorting, comes first (i.e. before Page B and Page C. $pages->get() returns a Page. If you did a $pages->find(), this will always return several pages (if it found them, of course). The important thing, as noted earlier, is that $pages->find() returns a PageArray. That means, several Page Objects. So, you cannot directly echo like so: $results = $pages->find('template=basic-page'); // cannot do this; it doesn't make sense since you have multiple items inside $results //...so, you would need to loop through it using a foreach echo $results->title; Think of it this way: // FRUIT: this is very specific. You are requesting a banana; not an orange, not an apple, but a banana. //...We will get you a banana $fruit = $pages->get('banana');// @note: pseudo code! // hence, you can do echo $fruit->title;// outputs 'banana' // BUT....if you want FRUITS...there are several fruits... $fruits = $pages->find('fruits');// @note: pseudo code! // if you did this, the question would be, what fruit was that again? // direct 'echo' doesn't make sense; // ...you need to tell us what fruit you want; apple? orange? banana? There's several fruit in here! echo $fruits->title; // aaah, so, we loop through the basket, one fruit at a time... foreach($fruits as $fruit) echo $fruit->title;// this will output each fruit in here in turn...apple; orange, banana, etc... Hope this makes sense.2 points
-
Often times, creating a side project is first and foremost scratching your own itch Or to start differently: Currently, I'm developing a site where I need CKeditor (and later jQueryUI Datepicker) outside of the admin, in frontend. I searched Google and the forums and found an approach to follow - but during the research the site laravel-recipes.com came into my mind (since I'm currently also looking into this framework). It's content consists of small, spot-on bits of information, for example: http://laravel-recipes.com/recipes/269 Just to think out loudly here, wouldn't it be nice to have a ProcessWire counterpart of such a site? processwire-recipes.com for example? Target group: Developers, from beginner to advanced Difference to these forums: Stripping the discussion part, concentrating on the info; and if done properly: bypassing the mediocre forum search, better tagging Difference to the official tutorial section: Focusing on not creating a whole site, but modular parts of it. Single solutions. For example: First child redirects (shameless plug, but this is the format of information pieces I'm having in mind) Difference to the API documentation: Situation-based ("I need this and that") instead of architecture-based Laravel.io (forum), laravel.com (official, and doc) and laravel-recipies.com possibly prove that these type of sites can coexist in a framework ecosystem, so I guess a recipes site would not cannibalize this forum here nor the doc section. A recipe site like this would live and die with its content, of course. I would be ready to share all the small pieces of information I encounter that would make a good "recipe". But that alone wouldn't be enough so this project won't survive without contribution of the community. What's your opinion on this? Yea or nay? Update: ...it just took, erm, nearly three months,... but here it is: https://processwire-recipes.com/1 point
-
Another proof-of-concept module: JsonNativeField Leverages MySQL >= 5.7.8's native JSON column type for key-value storage. This gives us the opportunity to store arbitrary (textual) fields in the database and allows us to search for them with plain subfield selector syntax, including wildcard operators. Possible applications are storing submitted form data or adding user-defined properties to their profile. Currently, the module is still really, really alpha, but I wanted to get input early on. Let me know what you think. Download from GitHub. Here are a few screenshots for anybody interested but unable to try for themselves: 1. First page with json field and custom subfields: 2. Second page with json field and custom subfields: 3. Searching through all subfields in the json field: 4. Searching only in a specific subfield: The interface is really rather crude still. The "delete" buttons only work after saving (have to attach listeners to the newly created entries yet), and I've got to straighten out supported operators for Lister to pick up. I'll see if I find some time tomorrow to work on these issues and brush up the visual side a bit.1 point
-
@szabesz by separate tutorial you mean to launch a new topic to distinguish from Launch&Learn? If you think this is a better idea, I don't have issues with that This morning I read about the tags and am already aware how to do it using PageAutocomplet so it is just a matter of time to put the code in. I find the idea behind tags added as child pages to allow all the freedom of usage via API (and the simplicity for a newbie to finish the job). It is true that this would require an additional core module to be installed, however, knowing the developers If the functionality, I have no issues using it Let's see how would that goes as after the tags comes the turn to the comments. The only thing to play with would be to put the tag cloud on the main page containing X-amount of tags. I guess, that it can be done through the page sorting, but will see about that...1 point
-
1 point
-
May be you can use two approaches. One is creating an API inside PW using special templates and responses. maybe using my Rest Helper https://github.com/NinjasCL/pw-rest heres an example https://github.com/NinjasCL/voxgram The other one is creating an API outside PW using an specialized rest framework and calling PW using composer. http://flightphp.com http://phpsx.org http://phpflow.com/php/restful-api-frameworks-for-php/1 point
-
v027 contains some code improvements. There are two new filters, "count" and "breadcrumb". The latter is a bit different from the rest because it generates markup but it has many options to fine-tune. Currently it doesn't generate any separators between the items, I think it's better to do with CSS but let me know if you think otherwise. root: root page to start the breadcrumb from (selector or Page). Default: Home page addHome: whether to prepend the Home page. Default: true addCurrent: append the current page. Default: false addCurrentLink: whether to add link when appending the current page. Default: false class: CSS class to add to the "ul" tag. Default: "breadcrumb". Pass an empty string to remove class. id: CSS id to add to the "ul" tag. Default: none (no id added) addAttributes: add "data-page" attributes to 'LI' tags with the corresponding page id. Default: false {$page|breadcrumb|noescape} {$page|breadcrumb:array('addCurrent' => true, 'addHome' => false, 'addCurrentLink' => true)|noescape}1 point
-
v123 is up, and here are the latest additions: 1.2.3 - Hotkeys: focus filterbox on alt+s 1.2.2 - title change case button improvements 1.2.1 - Misc: option to move empty trash confirmation checkbox above trash items1 point
-
To fix the toggle button height and width jumping, I had to add the following to #show-button: box-sizing: border-box; line-height: normal; padding: 4px 15px 2px 6px !important; width: 16px !important; So all together it looks like this: #show-button { bottom: 0; right: 0; z-index: 99999; position: fixed; width: 16px !important; margin: 0 !important; padding: 4px 15px 2px 6px !important; background: #FFFFFF !important; border: 1px solid #DDDDDD !important; font-size: 12px !important; cursor: pointer; box-sizing: border-box; line-height: normal; } Works in the default and Reno admin themes and my frontend theme. Hope that helps Here is the pull request https://github.com/adrianbj/TracyDebugger/pull/91 point
-
http://processwire.com/blog/posts/roadmap-2017/#whats-in-store-for-processwire-in-20171 point
-
1 point
-
This one? Looks nice to me If you were to write a separate tutorial as the development unfolds that would be cool.1 point
-
Sure, I did that. I did that as soon as I discovered that Cloudflares Rocket Script was causing the issue. Even before you posted the link. What I meant was that the info in your post could be included in the Readme file, as a known issue. So that other users don't need to spend a couple of hours in order to find the cause to this problem. /Jasper1 point
-
@owzim - Thanks. Jumplinks v1 doesn't support explicit optional trailing parts, so you'll need to create a separate jumplink for now if you want to capture foo=bar. However, if it doesn't matter what needs to trail the first parameter, then you can simply use project?id={id}{all} and leave the destination as-is. v2 will support this. You'll be able to wrap the optional part in square brackets and Jumplinks will add the optional part to the end of the destination if it appears in the source, and it'll also ensure the URL is structured properly. In other words, you'll be able to set it up like this: Source: project?id={id}[&foo=bar] Request: project?id=4 --> project/project-name Request: project?id=4&foo=bar --> project/project-name?foo=bar If the source is project?id={id}[!&foo=bar], however, then the optional part will not be added to the destination. I haven't actually worked on the feature yet, so it may change; but this is how I plan on doing it. (Speaking of which, forgot to add this to the roadmap!)1 point
-
... or you could try the Cloudflare rule I mentioned in my blog post to exclude the PW backend.1 point
-
I'm not sure it's worth looking into. Caching for backends is imho not the best idea to start with, so at best Ryan could mention it somewhere as "known issue".1 point
-
As best I can work out, looking at Admin > Setup > Logs > System-updater, I upgraded to 2.6.13 dev (which it is still on) about 20 minutes before I wrote that blog post, which I can only assume triggered the need for the post in the first place.1 point
-
hi, Old thread but I've just tested with MySQL 5.7.14 on PW 3.0.42 and did not encounter any problem so far.1 point
-
1 point
-
1 point
-
Okay, the job is done now. The final solution might not be too elegant, but it works exactly the way I want as I described it in the opening post. My search form has two additional selects: scope for setting the fields to search and mode for setting the search mode. kongondo and Robin S: I want to thank you once more – I wouldn't be where I am without your kind help. <?php if ($input->get->search_terms) { // ---- sanitizing text input ------------------------------------------------------- $search_terms = $sanitizer->text($input->get->search_terms); // ---- getting desired search scope, default = title + body ------------------------ if ($input->get->scope) { $scope = $input->get->scope; } else $scope = "t_body"; // ---- getting desired search mode, default = AND ---------------------------------- if ($input->get->mode) { $mode = $input->get->mode; } else $mode = "and"; // ---- template and limit settings -------------------------------------------------- $template = "pg_entry"; $limit = 50; $selector_complete = ", template=".$template.", limit=".$limit; // ---- replace multiple spaces with single space $search_terms = preg_replace("/\s+/", " ", $search_terms); $terms = explode(" ", $search_terms); // ---- both scope options: search title ---------------------------------------- // ---- mode: AND search if ($mode == "and") { $selector_1 = "("; foreach($terms as $term) { $selector_1 .= "title%=".$term.", "; } $selector_1 = substr($selector_1, 0, -2); // delete trailing comma and space $selector_1 .= ")"; } // ---- mode: OR search else { $selector_1 = "title%="; foreach($terms as $term) { $selector_1 .= $term."|"; } $selector_1 = substr($selector_1, 0, -1); // delete trailing pipe } // ---- adding template and limit values $selector_1 .= $selector_complete; // ---- scope: t_body, adding 2nd selector for body ----------------------------- if ($scope == "t_body") { // ---- mode: AND search if ($mode == "and") { $selector_2 = "("; foreach($terms as $term) { $selector_2 .= "body%=".$term.", "; } // ---- delete trailing comma and space $selector_2 = substr($selector_2, 0, -2); $selector_2 .= ")"; } // ---- mode: OR search else { $selector_2 = "body%="; foreach($terms as $term) { $selector_2 .= $term."|"; } // ---- delete trailing pipe $selector_2 = substr($selector_2, 0, -1); } // ---- adding template and limit values $selector_2 .= $selector_complete; } // ++++ matches for selector 1 (title) ++++++++++++++++++++++++++++++++++++++++++ $matches = $pages->find($selector_1); // ++++ scope t_body && limit not reached yet: matches for selector 2 (body) ++++ if ($matches->count < $limit && $scope == "t_body") { $body_matches = $pages->find($selector_2); } else { $body_matches = ""; } // --- matches found in body if ($body_matches) { // ---- remove duplicates already in title matches $body_matches->removeItems($matches); // ---- add body_matches to matches $matches->import($body_matches); } // ++++ Output search result ++++++++++++++++++++++++++++++++++++++++++++++++++++ if ($matches->count) { foreach($matches as $match) { // Output matches } } else { // Output no matches } } else { // Output no search term(s) } ?>1 point
-
1 point
-
Not to nitpick, but remember that $pages->find will give you a pageArray so it is possible that the $store->title might not work how you'd expect. If another child of Deals exists, then you might run into some errors. It would be better to use either $pages->findOne or $pages->get. If you anticipate that Deals might have more child pages, I would suggest expanding the selector as well.1 point
-
1 point
-
1 point
-
Update: Menu Builder Version 0.1.7. Changelog Fixed a bug that caused titles of menu items with apostrophes not to display properly in menu settings. Thanks @LMD Code cleanup and refactoring.1 point
-
you either leave the namespace or need to prepend all php function like RecursiveDirectoryIterator with an \ backslash like \RecursiveDirectoryIterator so it knows this function is not in the ProcessWire but in the root namespace..1 point
-
// Returns 10 pages, which are then further filtered, so it could even be none $lastEvents = $player->get("name=history")->find("template=event, sort=-date, limit=10")->not("task.name=donated|donation|absent"); // Returns 10 of the correct pages $lastEvents = $player->get("name=history")->find("template=event, sort=-date, limit=10, task.name!=donated|donation|absent"); Not sure what behaviour you want there, but there's a difference.1 point
-
Hi, Great module - it's just what I needed! However, I'm encountering a weird issue with some menu item titles. If a menu item title contains an apostrophe/single-quote, the characters following (and including) the apostrophe are removed after saving the menu. For example, the title "What's On" becomes "What". It's ok if it is the initial save after adding that menu item, the apostrophed title is saved to the db, but it is subsequent saves that remove it. It appears the characters are stripped when the title is displayed in Menu Builder's menu item editor widget. Currently, the work around is to just retype each menu item that gets stripped before saving each time. Using: Menu Builder: ver. 0.1.6 Processwire: ver. 3.0.471 point
-
@MaryMatlow, Seems you missed the third link in my post above . The array indices were changed to 'post_image_tag' => 'whatever', etc..Please see the whole list there or within the module code itself1 point
-
@gmclelland - I decided to go ahead with adding this anyway The latest version replaces the existing close (x) button with a hide arrow. This is what it looks like when hidden: In case anyone is wondering, this is quite different to the Enable/Disable button (either from the dedicated panel, or from the panel selector) because with this new option, even when hidden it is still capturing errors etc and when you unhide/show it will instantly show it's information without the need for a page reload. There is also a new module config setting to "Hide Debug Bar By Default". That should be self-explanatory, but keep in mind that once you have clicked on the show or hide buttons, cookies take over controlling its status. Please let me know if you have any problems. Just an FYI - I am not a big fan of this because you won't be alerted about non-fatal warnings/notices while the debug bar is hidden, but I think it's nice to give users the option if they prefer it.1 point
-
i can show a simple module to do this, the only thing delaying me right now is figuring out how to prevent the publish - I guess if you hook into saveReady, then you can check to see if the page status is published (since the request would have that set) and then if the image requirements are not met, you would set the status to unpublished, overriding the request; haven't tested this yet but will do so soon.. ok here is a try - note that once you install this module, you can keep adding stuff to it by adding your hooks to the init and then your functions below.1 point
-
The Console Panel now has a History stack and a separate Snippets stack! Hi everyone - this has been a long time coming. It was originally suggested by @bernhard back in early November. I want to thank @bernhard for the idea and feedback on draft versions, and @tpr who has contributed many ideas, style suggestions, and code to this functionality - sincere thanks to both of you! Snippets are automatically saved to the tracy config settings entry in the modules database table so that they are available on other browsers/computers have a dedicated save button - they are not saved automatically when running code save button only available when loaded snippet code is different from saved version so you know whether you have made changes has the ability to sort alphabetically or chronologically (date modified) no limit of number of snippets stored snippets can be deleted - a ✖ icon appears when you mouseover a snippet in the list History items are saved to local storage automatically saved when you "run" code comes with "Back" and "Forward" arrows for moving between history items currently stores maximum of 25 items - let me know if you think this needs adjusting Some other miscellaneous changes when running code, output is now appended to the results panel (like your browser dev console) you can used ALT/OPT+Enter keyboard shortcut to Clear and Run the "Clear" button now clears the results panel, but leaves the code intact Future ideas ability to easily export/import snippets to stack your ideas Please let me know if you come across any bugs or weirdness with anything - it's still pretty early stages!1 point
-
Just a quick status update: I've started implementing different field types (text, integer, float, date, date+time) with native inputfields. Types can be switched back and forth, and I'll make it hookable so custom inputfields can be added as well. Will be a while though, since it looks like I'll be busy with a lot of other stuff until the end of next week. Here's a teaser though...1 point
-
So this is sufficient, as in most cases in PW like fields. No isset() or empty() etc. if($session->cart_item){ .... exists or is populated } else { .... doesn't exists or is empty } You can also write, as always in PW $session->get("cart_item"); You can also use namespaced session $session->seFor("myshop", "cart_item", $cart_item); and get it with $cart_item = $session->getFor("myshop", "cart_item"); BTW what happens if hack your code and enter a "template=user, id=40, check_access=0" into your "product_id" POST?1 point
-
$session->cart_item is not a variable, which you could check for existance. It's an object ($session), which you ask for a specific key (cart_item). This will either return the item or null if the key is not found.1 point
-
this didn't work for me $grandchildren = $page->children->children; neither did this, or any other variations of this kind: $grandchildren = $page->children()->children(); what worked for me was this: $gp = $pages->get(5766); $children = $gp->children; foreach($children as $child){ // there was a ")" missing $gchildren=$child->children; // corrected from $children to $child foreach($gchildren as $gchild) echo $gchild->title; } you can also give all of the videos the same template and call them simply like this: $pages->find("template=video") // corrected from get() to find() after soma's reply or if you need the videos to have different templates: $pages->find("template=video1|video2|video3") // also corrected from get() to find() edit: Ryan, I also assumed parent->parent children->children would work. Why doesn't it? I'm sure there is a very interesting explanation involving methods and classes and lots of oop stuff1 point