Leaderboard
Popular Content
Showing content with the highest reputation on 06/20/2013 in all areas
-
Let's face it, the more you know about driving the faster you can drive your Porsche. If you are not skilled enough, you might get your car to 120 mpH, and that's your limit. Whatever product you build, you always have to compromise between accessibility (may be used by everyone) and scaleability (not for everyone, but the sky is the limit). PW has opted for the second route and that's a wise decision imho - though it clearly limits accessibility/popularity. There are enough CMS out there with which the less experienced can click together a website. A good example is Contao (though it is a good system with a strong foundation). Need a quick mockup, site structure, easy to use and maintain? Done in a second with Contao. Need a headline in two colors and therefore a nested span? And the whole thing must be maintainable by the client? Uh, think twice and check you budget again. No, from my point of view, the market gap is there for a system like PW, not for another click-ready-solution. I'm not a coder at all, my PHP skills are on a very basic level. But I feel as if I always get the support I need though it remains true that everybody has to climb his learning curve by himself. That's the price you have to pay for an open system. Just my two cents.6 points
-
I think that this is for folks that prefer to copy/paste stuff. But for people that fully read and understand the docs, they can make their own examples, tips and tricks. They are the ones here having the most fun and responding to all the questions. Many assume the system to be much more complex than it actually is simply because they are giving more weight to tutorials and copy/paste snippets of code from the forum rather than the bigger picture that is emphasized by the docs. Though I know everyone learns differently. For me personally, I don't learn well from tutorials or snippets… even I get lost in most of the ProcessWire tutorials I've tried to follow. I need to know the big picture. And ProcessWire's big picture is really, really simple. Other systems are far more complex… I think an issue is that people aren't used to understanding the big picture because they assume a level of complexity that isn't there with ProcessWire. They want to know how to do this or that little thing, without considering that they really can know how to do everything. The closest path to knowing how to best develop in ProcessWire is to read the docs. The pre-requisites are knowing front-end development (HTML & CSS), and optionally a little PHP. Though even people that don't know any PHP can do more than they could with a template engine. But for people that do know a little PHP, anything is possible. If I recall, Diogo mentioned that he printed out all the pages in the /api/ section of the site, took them to a park, and read them in an hour or so. Despite not starting out as a coder, he came back here knowing how to do anything. He can literally answer any question because he knows the big picture. This is a good way to put it. My opinion is that even someone with no understanding of PHP will still be able to create more on their own with ProcessWire than they could in another system. But for those that really want to "drive fast" and see how far they can push it, they'll have a much stronger engine at their disposal than they might in another system. For those people, php.net becomes a valuable documentation resource too.5 points
-
hi all, online since today, a new site for a big doctor's practice specialized in prenatal diagnosis: praenatalmedizin-koeln.de the site replaces an old outdated site and i put special effort to maintain the very good serp ranking of the old site. that's why there is an exhaustive faq page, an additional glossary page, and the tagline on top of each page. the calendar of recommended examinations (see bottom of page /untersuchungen) was done with the page field type. the editor may allocate any page from the /untersuchungen section to the calendar with the help of page field type. once allocated, the page qualifies for the calendar if there is an entry in the respective field SSW (saying for which week the examination is recommended). if this field is filled, the information is automatically added to the calendar and sorted. if no "ssw" is given, the page doesn't show up in the table. your comments are welcome. please let me know if you find any bugs. modules: redirects, email obfuscator, after save actions3 points
-
Give three programmers individually the task for a specific application and you'll get three complete different solutions. Ask them to look through each others code and all will correct each others.3 points
-
pwired: if docs would have all those examples, one by one - it would be just the same that you bought a box of legos and got 3 000 000 pages long manual that would show all the possible combinations that could be done. When you learn the basics: $page, $pages, Page/Wire Arrays, selectors etc and learn how to use cheatsheet (and soon source code), you really can find combinations like that. But, to answer your question: DIOGO: $pages is explained here: http://processwire.com/api/variables/pages/ ->find() (and selectors in more common, ie. what to put inside find) is explained here: http://processwire.com/api/selectors/ (also first item here: http://processwire.com/api/variables/pages/) ->has() is explained here: http://processwire.com/api/arrays/page/ TEPPO: $page is explained here: http://processwire.com/api/variables/page/ ->is() is explained here: http://processwire.com/api/variables/page/ (and again, concept of selectors) SOMA: Operator (^=) that Soma uses in his selector is explained here http://processwire.com/api/selectors/3 points
-
3 points
-
Again, as I said in my previous post, if you give the user only view permission, they won't get into the backend. When they login through admin login you'll get a "continue" link that links back to the website. So without doing anything you already got those user from accessing the backend, but they still can use the admin login screen if they know it, but it's not issue at all. In one of a project I used this technic with a front end sign in and login http://muetterhilfe.ch/angebot/online-beratung/anmeldung/ Similar to what you say, I create a user page after they successfully registered, and save that in a page field on the user. After they login they get redirected to their page with a simple profil page and form to ask questions a expert then can answer. All the "permission" and handling is done without any permissions or special roles (just the user role with base view permission) just in the templates with absolutely basic API code. User's can't access other user pages, and this is simply done in the user page template, it checks if this really is the current user page. It all requires minimal coding and setup. It's so simple it's scary and often you think this can't be, but it is. When I find the time I'll maybe make a write up or simple profile that shows this simple setup.2 points
-
Hello All, So we redesigned our company website (finally!!!) that was under redesigning for over a year. And I'm very excited to present it here. My initial (very firm) decision was to make the new site using Textpattern as it fulfilled almost all our requirements and developing a site using Textpattern would have only taken a day or two for me. But ever since I've found ProcessWire, I can't think of using Textpattern anymore. It's like cheating on your wife for a new girl you met just a while ago who's slimmer, sexier, fulfills all your demands & most importantly, never restricts you from doing anything that you wish, unlike your wife who has already set rules & restrictions. Not that I'm criticizing Textpattern in any way, it's a great reliable CMS which is easy to use & customize, but like I said, PW's making me cheat on Textpattern. Coming back to real topic, here I present our website: www.adveti.com This is the very first PW site made by me that's gone live, few more are in queue. About the site, it's a responsive mobile friendly website, for that we use a tiny CSS framework which I had made a while ago, we call it Tiny Grid. It's still under construction. We've to upload many of our projects. Just to get the site launched, I've added only about 6 projects that we did recently. There's a lot more work to be uploaded. It's a very simple & basic site which mainly focuses on displaying our work, so we've tried to keep as simple as possible, minimal you can say! FormTemplateProcessor module proved to be very useful in making project planner which helps in providing clients rough estimate of the project cost, thanks to Ryan for that. So I'd love to hear your feedback, if you like it, hate it, have suggestions,everything & everyone's welcome. Thank you all, and sorry for the long post2 points
-
To create a sitemap.xml you can use Pete's Sitemap XML module, or you can create a template file and page to do it for you. This post explains how to create a template to do it for you. The benefit here is that you may find it simpler to tweak a template file than a module, though either is a good solution. Here is how to do it with a template file and a page: sitemap-xml.php <?php namespace ProcessWire; /** * ProcessWire Template to power a sitemap.xml * * 1. Copy this file to /site/templates/sitemap-xml.php * 2. Add the new template from the admin. * Under the "URLs" section, set it to NOT use trailing slashes. * 3. Create a new page at the root level, use your sitemap-xml template * and name the page "sitemap.xml". * * Note: hidden pages (and their children) are excluded from the sitemap. * If you have hidden pages that you want to be included, you can do so * by specifying the ID or path to them in an array sent to the * renderSiteMapXML() method at the bottom of this file. For instance: * * echo renderSiteMapXML(array('/hidden/page/', '/another/hidden/page/')); * */ function renderSitemapPage(Page $page) { return "\n<url>" . "\n\t<loc>" . $page->httpUrl . "</loc>" . "\n\t<lastmod>" . date("Y-m-d", $page->modified) . "</lastmod>" . "\n</url>"; } function renderSitemapChildren(Page $page) { $out = ''; $newParents = new PageArray(); $children = $page->children; foreach($children as $child) { $out .= renderSitemapPage($child); if($child->numChildren) $newParents->add($child); else wire('pages')->uncache($child); } foreach($newParents as $newParent) { $out .= renderSitemapChildren($newParent); wire('pages')->uncache($newParent); } return $out; } function renderSitemapXML(array $paths = array()) { $out = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; array_unshift($paths, '/'); // prepend homepage foreach($paths as $path) { $page = wire('pages')->get($path); if(!$page->id) continue; $out .= renderSitemapPage($page); if($page->numChildren) $out .= renderSitemapChildren($page); } $out .= "\n</urlset>"; return $out; } header("Content-Type: text/xml"); echo renderSitemapXML(); // If you want to include other hidden pages: // echo renderSitemapXML(array('/path/to/hidden/page/'));1 point
-
EDIT: Fixed missing top right button (didn't show 'cause I've been using old main.js file...) EDIT2: Fixed font issue, it display now correctly all European characters, cyrillic characters (Russian, Macedonian, Bulgarian, etc.) and also Greek characters (slkwrm, apeisa) Fixed sidebar using media query / added scrollbar if window is to narrow (apeisa) Downsized page title font a little bit (diogo) Reworked page list sort selector (apeisa) I've made a new admin theme called "Moderna", screenshots are attached below. For full user experience, download cirkuit.zip (it's TinyMCE theme) and put it into this directory: /wire/modules/Inputfield/InputfieldTinyMCE/tinymce-3.3.9.2/themes/advanced/skins/ then open InputfieldTinyMCE.js located in /wire/modules/Inputfield/InputfieldTinyMCE/ directory and replace skin: "o2k7" with skin: "cirkuit". Hope you'll like it... cirkuit.zip moderna-admin-template.zip moderna-admin-template-v1.1.zip1 point
-
Greetings Everyone, I just completed building a site which serves as a companion to a book published by Rutgers University Press. The book is about Holocaust films. The author uncovered these films during extensive research in Russia, Israel, and elsewhere. This site is designed to be used as a college classroom resource. Teachers will go to the site, play movie clips for their class, then use the chapter summaries and discussion questions as further materials. For the video pages, I used the video.js player. Every movie page includes an .mp4 and a .webm file, in order to cover as many browsers (and tablets) as possible. The movies play in regular and full screen. Although the site is launched, I am still planning to build additional sections for "educator resources." I may also make some style changes in the coming weeks. Using ProcessWire made the building of this site very smooth! The author can easily log into the site, add or edit chapter text and discussion questions, and upload video files. She can also easily edit any of the static pages. This is a relatively simple site that will get a lot of practical use in college classrooms. Here it is: www.phantomholocaust.org Thank you, Matthew1 point
-
Hi, First, some introduction... I'm new on PW, just started yesterday evening and I'm very enthousiastic! I have 10 years+ enterprise experience in PHP (owning my own software company for 8 years). I have developed an enterprise CMS myself for lawyers, accountants and all sort of enterprise users which focusses towards handbooks (ISO and the likes) which is used by 2000+ companies (incl. government) in The Netherlands. Besides this, I just do some websites for friends and family in my spare time (which I do not have because I'm a dad of 3 too). I stumbled upon PW yesterday after I (again) completely freaked out at Joomla. I know this software when it was called Mambo 4.5.2 and I have created many componenents for it, knowing it from the inside. I always (after the first 3 months) hated it, but you know, when developing a small website it was the tool at hand for me because I knew it so well. And just every time I created a website I got frustrated, but well I got there and "OK, next". But this week, after 4 days of trying and reading and CCK extensions modules overrides custom layouts and all this stuff which makes me sick because its inconsistent as hell, I decided to just QUIT on joomla. It makes me cry. No joy in developing a small website. It's always about fitting in their model instead of the other way around. (And somehow, WP (which I don't know) feels the same way but different) Having said all this, did I mention I am very enthousiastic about PW? Well, I am. I have created in just one day (or half a day) what I wanted to do with Joomla and couldn't do it in four days. Even while I didn't got any sleep last night due to 5 weeks old baby etcetera. So, I'm happy with PW. Very happy. It just delivers. And I'm not familiar with the jQuery syntax (mostly used Mootools in my own software). It is just intuitive. I hope I stay this enthousiastic. But I'll gain some trust every step I make with it. Of course, there are a few things which I don't get directly, but I can search and read. But I wanted to just introduce myself and say a big THANKS for PW to Ryan and all the others. There is something I don't really grasp yet. Like this: I have several news items. These items are linked to from products. This works very nice But of course I want to have an index of all the news items. I can make a news-index template, and just make one. No problem. And then, I have a several review items, and several quotes. And I want them linked to products, no problem. But have an index too. Now, I can make 3 index pages. But somehow, they are similar to each other. Thus, Why don't create a 'polymorph' 'index' template. Which refers to a certain template (like, news, reviews, quotes) and loades all the items. Somehow, I just didn't came across this idea in the docs, wiki or forum. Perhaps I didn't read good enough, and I'm the first to admit I did not spent too much time with PW, but I'm curious if these kinds of concepts are 'the PW way to do things'. Another question/thought I have is about the data model. But thats maybe not the right place to ask right now....Is there something I can read about the thoughts and concept of the datamodel? Thanks in advance, I hope to use PW for my upcoming website projects and just want to finish my first stuff in the following weeks.. So you'll possibly see me some more on this forum. Ow by the way just one point of feedback: when doing my research yesterday, I thought that there were only video's available to get to know PW. After a while I stumbled upon the wiki and getting started links ! Wow. That saved time. But I wonder: why isn't that on the homepage? Every developer just wants to know about this I guess... After all the horrible forums with joomla 'experts' a forum isn't the first place I go look for documentation and help, you see..1 point
-
Interesting… I have exactly zero unused designs from last two years, I think.1 point
-
Greetings, If you have a chance, please post some code on how you accomplish this. What I'm looking for is the best method for directing different users to different pages after logging in. Admins/Super Admins go to the admin page; editors and members (for example) go to a specified URL. In the admin area, we can specify a URL where people go who don't have rights to see the admin page, but that bypasses the login screen. What we need is a way to let them log in, then specify the URL they go to AFTER logging in. Thanks, Matthew1 point
-
I have built pretty complex sites with PW and I remember feeling ankward of having similar template file per listing page. I thought that I would use alt-template filename all the time, but haven't actually used that much. And I don't see myself using it much in future neither... After revisiting sites after year or so, I love the fact that when I want to extend something, I always know the "starting point" (consistently named template file). And important to notice: having separate template file for each of your "index templates" doesn't mean you have to do any code duplication. Includes, modules, functions... what ever suits your workflow best Oh and welcome! You will definitely enjoy PW!1 point
-
Ah no not at all. All you do with api on front end to add or save content is non access aware and it does what you tell it to do. You could take roles and permissions into account and most likely this is what you do. PW has those checks also implemented same as you would do on your front end. The edit page screen wont load and throw an error if you dont have permission but you're not using the admin processes in your frontend so you take care through api on your own.1 point
-
I originally missed the issue with language switchers not working on the 404 page because all the instances where I'm using language switchers, I was only have it show the language switcher if the page was not the 404 page. The reasoning there is just that in my case, there wasn't much point in being able to show different language versions of a 404 page. If your situation is similar, I recommend simply not showing the language switcher when on a 404 page. Though if you want the switcher to redirect back to the homepage, that seems like another decent approach. But here's what I did: if($page->id != $config->http404PageID){ // render the language switcher }1 point
-
1 point
-
That's essentially what I posted above, though in a different context (module config rather than ProcessPageEdit). If you wanted one in ProcessPageEdit, you'd probably want to create a new Fieldtype for it. Actually, just checked and it looks like Hani already has.1 point
-
The biggest issue that I can see here is that you don't have page numbers enabled for your template. ProcessWire putting in the "page=2" is a signal of that. So before you do anything else, go and enable page numbers by editing your 'search' template–you'll see the option to enable page numbers on the URLs tab. When it comes to dealing with your 'vendor' field, I recommend whitelisting it to a string in whatever format you want to extract it. For instance, maybe you want to use commas as a separator rather than pipes. You can whitelist it like this: $input->whitelist('vendor', implode(',', $vendors)); // if vendors is an array $input->whitelist('vendor', str_replace('|', ',', $vendors)); // if vendors is a PageArray Though you could certainly stick with "|" pipes if you preferred. But what I don't want to see you do is bundle that right from $input->get->vendor into a selector without validating it first. So switching to another separator makes that intention a little more clear. For instance, your form processor might capture and sanitize the vendor variable like this: if($input->get->vendor) { if(is_array($input->get->vendor)) { // array from form submission $dirty = $input->get->vendor; } else { // convert from your CSV string to array $dirty = explode(',', $input->get->vendor); } $vendor = array(); foreach($dirty as $id) $vendor[] = (int) $id; // sanitize to INTs $vendor = implode('|', $vendor); // convert to 123|456|789 string, ready for selector } else { $vendor = ''; }1 point
-
The strtotime call isn't technically necessary. You could also just do this: foreach($programs->find("program_start_date<04/01/$year") as $program) {1 point
-
public_html --- cgi-bin --- webapp (this one is subdomain) ------ .htaccess (updated by pw during installation) ------ index.php (created/updated by pw during installation) --- site --- wire --- .htaccess (updated by pw during installation) --- index.php (created/updated by pw during installation) @fmgujju great to hear you got it working, but your configuration seems wrong to me. i understood you want to run a separate php application under /webapp, that is not a pw install. in this case your /webapp/index.php and /wepapp/.htaccess files shouldn't belong to pw but should be replaced by dedicated files of the application. @teppo your are definitely right, but unfortunately some isp doesn't allow for such a folder structure. this weekend i had to deal with a client's account at isp hetzner and they demand for precisely the same structure fmgujju has: primary domain point to /public_html and all subdomains point to dedicated directories within /public_html. don't know why they demand for this, but you don't have a choice.1 point
-
Dear Kongondo, Soma and Matthew, Thanks for your input... Soma, where would you put your code example? In default.php, as Kongondo suggested? Would it be possible to suggest exactly where in default.php, or elsewhere, you would put it, with a complete example? When I looked at default.php, there's a lot going on. The function would have to come into play right after a log in by someone with a barred role. I think this type of code would be very useful, even as a default module. For example, one could configure the backend to only allow xyz types of roles, or perhaps even easier, offer an option to block certain roles. Like an include and exclude list. For the front end: I'm developing a scheme for members with a custom login at /members/, so that the user (who is an actual PW user with the role of 'member') would get redirected to a custom home page just for them, on the front end. When the user registers as a member, from a custom front end page, the script would not only create a user account, but would also create a member home page under the /members/ url, e.g. /members/1097-8247913542/ This would serve as an account page for that member, and offer a variety of functions for the member. The '1097' is a standard user id, and the longer number is randomly generated, with the whole thing used as an account number, used for authentication on every page under the member's section. I made it a hard-to-guess number for just a bit of security, so that the account urls of other members would not be easy to guess. I've created a set of template/field groups that all use the user_id and the account_url, and have structured the member pages just like a regular /section/page/ tree. Using Ryan's idea of not passing html until the end is a good idea, allowing for redirection when necessary, but I'm not just using a master control script because I want to provide different functions for each type of member branch or page. Thus, I'm going to create a template file for each type of page in the member section, and simply include headers and footers, etc, but include them as variables that would get output at the bottom of the page. I've written apps with a huge control script, running off of one url, but the files were, well... huge. I feel now that placing the functions that apply to one type of page or section url, in the template php file, allows those urls to load much faster, with less overhead. I think that PW's design, in this fashion, is excellent. It also allows an admin in the backend to easily navigate through all the members' pages, since each member's sub-pages are all under their account 'home page', in the tree. So... I think I've got the front end concept, but blocking the backend admin from any role that isn't a 'backend' type of user would be a great thing. Thanks, all, Peter1 point
-
I'm not so sure I just tested out the module to confirm what I thought. Here's what the module does. 1. It only does it's thing if the user has the role *editor*. 2. It allows users with the role *editor* to edit only their own pages - pages that they created. 3. To reiterate #1, module doesn't do anything if the user doesn't have the editor role. Now, before I continue I'd just like to say that I've already found a use for this module - restricting certain users to edit only their own pages. and it kind of solves part of a problem I had with my PageEditPerRole module.. So, thanks Soma Continuing, I believe what Peter was asking for was: 1. Users can only edit their own pages. (pages they created) 2. If the user has an *editor* role, then they can edit other people's pages. I think #1 can be improved to say that "users with role *author* can edit only their own pages". Then, there would be another role check for the *editor* role (or something similar) who can edit everything. As below: <?php /** * Page edit per user created id * */ class PagesCreatedEdit extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'Pages created edit', 'version' => 1, 'summary' => 'Page edit only for created pages by user', 'href' => '', 'singular' => true, 'autoload' => true, ); } public function init() { // add edit permission hook for admin pages $this->addHookAfter('Page::editable', $this, 'editable'); } public function editable($event){ $page = $event->object; //I don't think we should stop users if they already have permission to edit //Permissions should be additive IMHO - other modules could grant edit permission. if($event->return) return; //I'm not too good with this kind of conditionals. basically, stop if user doesn't have either of these roles //The idea is, the presence of these roles trigger when this module *runs* - does it's permission check //(obviously the module is already running) if(!$this->user->hasRole("author") && !$this->user->hasRole('editor')) return; /** TODO: author and editor roles may be another name or could be multiple roles **/ //get highest "role type" $roles = $this->user->roles; $is_editor = false; //probably don't need this foreach($roles as $r){ if($r->name == 'editor'){ $is_editor = true; $role = $r; break; } elseif( $r->name == 'author' ){ $is_editor = false; $role = $r; } } //make sure role has page-edit permission. I know user may have page-edit permission from another role. //but let's not consider that for now. if(!$role->hasPermission('page-edit')) return; if($is_editor){ $event->return = true; }elseif( $page->created_users_id == $this->user->id ){ $event->return = true; } /** * Caveats: (for now) * * If user has both author and editor roles, then this module will use the editor role for permission check. * This means if editor role doesn't have page-edit permission, user won't get permission even if author * has page-edit permission. */ /* if($event->return) { // only if edit rights are true if($page->created_users_id == $this->user->id){ $event->return = true; } else { //don't think we need to set to false //$event->return = false; } } //*/ } }1 point
-
@totoff is probably right and his answer makes a lot of sense in this context. Just wanted to add one slight clarification (I hope..) from my point of view: Generally speaking it would be a very bad idea to have directory containing a subdomain inside directory containing main domain -- if we're really talking about subdomains (webapp.mydomain.com) and not directories under main domain (mydomain.com/webapp/) here, that is. That kind of setup will only result in logical (ie. what happens when you navigate to mydomain.com/webapp/) and practical (ie. running ProcessWire inside ProcessWire) problems. A subdomain doesn't have to have anything in common with your main domain (it's another domain after all) and it's definitely nothing like a sub directory, which is your current setup seems pretty messed up to me. If possible, something like this would seem better option: /www/mydomain.com/ /www/webapp.mydomain.com/ .. or perhaps this, which is what one webhost I'm using does (though I've no idea why): /mydomain.com/www/ /webapp.mydomain.com/www/1 point
-
Don't know if you guys already recognized that you can now open a page in the page tree by double clicking the title. It's in since a couple months and I think, including me, didn't recognize it's there. Have a nice day!1 point
-
Let's face this especially more for processwire than for modx evo: the more you know about php and coding in general, the more you can do with processwire. Lot's of valuable info, examples, tips and tricks to apply the "open" potential of processwire, both for newbies and rookies are simply not in the docs but scattered all over the forum. Therefore I started indexing that info, tips and tricks and keep it on a pendrive, always available. Before I start to do something with processwire I first read through all the examples, tips and tricks otherwise I would not use half of it's potential. That is so true, see also above commenets. And it shows that this forum is filled with a lot of experienced and skilled coders who take their skills and experience for granted while newbies have difficulty to follow and keep up with them but would really want to because of pw's big potential.1 point
-
I've tagged release 1.0.0 and the module is now listed in the modules directory.1 point
-
Just pushed out an update to the module on github https://github.com/ryannmicua/PageEditPerRole and thought I'd ask for feedback. I did hack core though. The module needs ProcessPageAdd::getAllowedTemplates() to be hookable - required for #2 below. Right now, you can do the following: Select pages that role can edit. (I'll just say "role" instead of "users with role" but hope you understand) Select pages that role can add child pages to. requires the parent page to be editable by role (set in #1) and in module config, requires permissions to be considered further up the branch - if you don't, you can't edit the child page after you add. Next: - Improve #2. I'm thinking of adding another field - "Parent page where role can edit child pages". This is for situations where you'd like to allow users to create pages under a parent but not allow them to edit the parent page. This way, you don't have to enable the permissions to be considered further up the branch in module config.1 point
-
Nobody? Ok, since the tags introduced to the image field is just a plain text field, there's no other way than to loop all pages that have images loop all images to grab all tags, parse them to array and merge them. This gets you there but doesn't scale well. (Would those tags be page relations it would make it very easy to output all tags. I'm more of a fan of using page fields for tagging, but there's no image field with page tags and I use different image system if there's a lot of images with tagging and galleries. My ImageManager is one of the tools to have a page as image and you can attach as many fields to the image template to get those things done.) I often thought about what would be the best ways, with words in text fields all over the site, to collect them and I think you have two possibilities. Raw SQL query, or the above loop all pages and make that a markup cached snippet, if the amount and time to generate the list takes long, that runs every other day or hour. Also have as many restrictions, for template or parent, as you can get to make the query a little more efficient. To show what would be the API way you already got a good start and intuition with 2 foreach. The following collects all tags and makes a unique array to create a link list. EDIT: You can use url segments or GET parameter for the links. Since PW urls doesn't allow special chars there's a workaround inside the code now. /** * collect all tags * ====================================== */ $alltags = array(); // container $use_urlsegments = false; // find all pages that have images with tags $parray = $pages->find("template=basic-page|gallery, images.tags!=''"); // loop pages found and collect tags from images foreach($parray as $p) { // find all images that have no empty tags, yeah you can // also use find on Pagefiles array! $images = $p->images->find("tags!=''"); // loop them and add tags to array foreach($images as $im) { $tags = $im->tags; // convert "," and "|" to space and create array using explode if(strpos($tags, ',') !== false) $tags = str_replace(',', ' ', $tags); if(strpos($tags, '|') !== false) $tags = str_replace('|', ' ', $tags); $tags = explode(' ', $tags); // convert tag value to a page name using beautifyer, ü => ue, ö => oe // since special chars are not allowed in PW urls foreach($tags as $tag) { $alltags[$sanitizer->pageName($tag, Sanitizer::translate)] = $tag; } } } /** * generate links with tags as urlsegment * ====================================== */ // make the array unique and create a tags nav from it // add tags to the url of the page to later read it and // render a list of pages echo "<ul>"; foreach(array_unique($alltags) as $key => $tag) { if($use_urlsegments) { echo "<li><a href='{$page->url}$key'>$tag</a></li>"; } else { echo "<li><a href='{$page->url}?tag=$tag'>$tag</a></li>"; } } echo "</ul>"; /** * find all pages with the supplied tag * ====================================== */ // enable url segments on the template if using url segments if($input->urlSegment1 || $input->get->tag){ if($input->urlSegment1) { $tagvalue = $input->urlSegment1; // get the original tag value text from the cached array $tagvalue = $alltags[$tagvalue]; } if($input->get->tag) { $tagvalue = $sanitizer->selectorValue($input->get->tag); } // find pages with images having the requested tag $pa = $pages->find("images.tags~='$tagvalue'"); if(count($pa)) { echo "<h2>Pages found</h2>"; echo "<ul>"; foreach($pa as $p) echo "<li><a href='$p->url'>$p->title</a></li>"; echo "</ul>"; } } What was the other question again? And of course also found in my ever growing gist archive https://gist.github.com/somatonic/5808897 I'm too lazy to brew a SQL that does the collecting part. But there's people more clever than me that can help.1 point
-
I've wanted to add this myself. While a big highlighted word may be distracting (right Dave?), finding the particular reference you searched for in a big page of text is equally frustrating and some form of delineation of the search term is helpful. However, since the search results page only displays the title and summary, often the search term itself isn't present on the search results page and the highlight doesn't actually get a chance to work. It helps to be able to pass the value of $q onto the page the user clicks in the search results. As Soma suggested, the easiest way that I found to do that (although there may be a better way) is to add: foreach($matches as $m) { $out .= "<li><p><strong><a href='{$m->url}?q={$q}'>{$m->title}</a></strong><br>{$m->summary}</p></li>"; } Which then passes $q onto to the next page so it can be accessed by .highlight. Works for me. Simple and easy on my brain. I should add you then need to add the following to the script at the bottom of the page: <script> $("body").highlight("<?php $q = $input->get(q); echo $q; ?>"); $(".highlight").css({ backgroundColor: "#FFFF88" }); </script>1 point
-
It seems like a generally good review, and very glad to see it. This is just the sort of exposure that really helps the project, so I'm very thankful for the review. Though it also seems like the review may have been based on a very brief experience with ProcessWire (maybe the demo?), as there's nothing to indicate the author(s) used it to develop anything, or know the system particularly well. I think this was primarily a good surface review (and nothing wrong with that). ProcessWire may be fine when you look at it on the surface, but it really shines when you actually use it, know it and develop in it. I think this is something most ProcessWire reviews miss. (CMSCritic.com is the only one I know that really gets it and has put ProcessWire through its paces). For example, the comment about global variables, among other things, seem a little out of left field to someone that knows ProcessWire well. I'm glad they thought our API was interesting, but I'm not sure they understood they understood the extent to which this is the driver of the system. The review stated the documentation was lacking, but I bet the author(s) didn't read the docs. People that do commit and read the docs tend to get a ton out of it. We probably wouldn't have nearly as active of a forum if everyone read the docs… for the record, I prefer having an active forum and getting people involved in the community, even if many questions can be answered in the docs. If we have a docs problem I think it's one of digestibility and structure rather than one of documentation scope. Outside of these things I think the author did a good job with the review and got a lot of points right. In fairness, if I was reviewing another CMS, it's unlikely I'd go develop a full site in it or read all the docs, etc. ProcessWire is a system where it's really about what's underneath rather than what's on the surface, and I think that's something very difficult to capture or communicate in review.1 point
-
@pwired, there isn't any software that keeps compatibility with old versions of modules forever. That's why I think it's great that you don't have to use lots of third party modules with ProcessWire, and everyone should be aware of the risk of making a website completely dependent of them. Anyway, no one is forced to upgrade immediately to a latest version (or even at all), and Ryan shows he is always very concerned about breaking things for people, so I'm pretty sure that when it comes the time when that step really has to be taken, all modules (or a good alternative to them) will be already compatible. One thing I think it's important to keep in mind here is that software has to evolve. And this evolution will always be a balance between backwards compatibility and new and better features. You really don't want to use a software that stopped in time...1 point