Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/16/2012 in all areas

  1. As for adding a class to the current page based on the current's page URL name and the parent's URL name, you have many options. Here's how I might do it, by adding a class to the body tag that would make it possible to target any element on a page in your CSS: <body class='<?php echo "page_{$page->name} parent_{$page->parent->name}"; ?>'> If you were on a page with URL "/news/press/", the result would look like this: <body class='page_press parent_news'> Rather than assigning body classes based on the current page and current parent, I usually find it's more convenient to assign a class based on the current section, or "root parent page" as it's called in ProcessWire. Typically these section pages are those that appear in the top navigation. Having every page identify it's section via a <body> class means we can easily highlight the current section in the navigation with our CSS. So here's how I might output the body tag: <body id="section_<?php echo $page->rootParent->name?>"> If we were on the page /news/press/, the result would be: <body id="section_news">
    1 point
  2. Currently all users have to have the 'user' template. However, you could add child pages below a user page (or role page) and perhaps keep some of your custom data/settings there. In order to add children to these pages, you have to edit the 'user' or 'role' template and click on it's 'family' tab and update it so that children are allowed.
    1 point
  3. Testing it right now and seems solid. Many thanks to Ryan, this'll come in handy
    1 point
  4. Okay I talked with the web hosting provider about the issue and indeed as Ryan's guess they said it had to do with a mod_security rule. The web host admin did something to the account and now upload works fine. Cheers
    1 point
  5. Wow, a bunch of great responses already. @Soma, thanks for that code. It seems to fit right in with what I'm thinking - I will keep that in mind as I start to experiment. I'm thinking of that page field you mention on the user object as the account. Each time a new account is created or a new user is added to an existing account, it gets the account "page" added to it. Same with all of the data that user creates. The actuai pages in my app (Dashboard, Team Members, for example) are viewable by everyone, but get their data based on the account of the active user. Also, thanks for the other framework recommendations. The more I think about it, the more I realize I want to stick with what I know for this project, which means doing it with PW. I'm very excited to start geting into this
    1 point
  6. Not sure if something like this could be helpful to consider here. I'm using a simple module for page/branch level access on user level. There's a simple page field attached to the user template. This allows to select 1 or more page from the site tree. So a user could have edit access for one page or a whole branch (inherited from 1 parent page) I then have a module that does hook into Page::editable and determine if the user has edit access for that page. The module looks like this: ... public function init() { if($this->user->hasRole("client")) $this->addHookAfter("Page::editable", $this, 'checkpermission'); if($this->user->hasRole("client")) $this->addHookAfter("Page::addable", $this, 'checkpermission'); //if($this->user->hasRole("client")) $this->addHookAfter("Page::viewable", $this, 'checkpermission'); } public function checkpermission(HookEvent $event) { // if it was already determined they don't have access, then abort if(!$event->return) return; $page = $event->object; $parents = $page->parents; // run check for parent pages and allow recursive inherit access foreach($parents as $p){ if($this->user->editablepages->has($p)) $event->return = true; } // then run check on selected single pages if(!$this->user->editablepages->has($page)) $event->return = false; } ...
    1 point
  7. Hi Ryan, Thanks for your answer, php 5.1 was a typo, I'm using 5.3.2 I've done some tests running processwire as mod_cgi and running processwire as mod apache, both running a bare bone github install (main repo from today) and called a execution time and you're right: mod_cgi is a tiny tiny bit faster but uses alot more RAM while doing so (after 1000 refreshes, mod_cgi spiked at almost 300Mb in cycle, while mod_apache stayed at a steady 68Mb) runtimes (after 1000 calls) mod_cgi: page runtime: 0.0476528 sec mod apache: page runtime: 0.0479234 sec so I'm switching my server to mod apache, and looking into APC Love your markupCache, I've been succcessfully using it on 2 projects now (caching large header elements) Looking forward to the new Page > write to filesystem or not again, thanks for everything!
    1 point
  8. Hi all, I know it's been awhile, but I'm just now checking back on this thread. Thanks for all the kind words - I'll be sure to pass them along to the folks on our team who actually did the design for it (I'm only responsible for the guts of it, not the prettiness). @ryan, I am using template level caching - I have each template set to clear for all pages including the home page on each save, and to save the cache for 24 hours. Without this aggressive caching, I think the site would be too slow in the real world. @AnotherAndrew, in this case the videos are just text fields, representing the main video file name. We are using the JW Player, and do have HTML5 compatibility setup, so the mp4, ogv and webm files are all named the same, save for the extension. For another site I did with PW - on which a client is making updates, including adding videos - I've set it up so that they upload the videos through ProcessWire. Knowing I can't count on the client to upload the HTML5 safe formats, I restrict the file field to mp4 only, then do a check for the existence of the other versions, changing the JW Player config as needed for each instance. I was thinking that, as we continue to use ProcessWire for sites going forward, that I might build a module that uses the Zencoder encoding API, along with JW Player, to allow full HTML5 compatibility for any video file the client uploads. I'll keep the community in the loop on that effort. Thanks again all.
    1 point
  9. Hello, I'm eisenberg partner. Thanks for your quick answer. We are integrating PW into OpenCart an would like to run it from a menu option in OC admin. What I'm thinking is to supply PW a user/password from the OC application. Let me congratulate you for what I think is the best CMS for developers.
    1 point
  10. Thought I'd just add what the forum helped me find. If you are looking for a replacement for the "if count" and "switch" methods in EE then the following code may help you. I should point out that there may be better ways of doing this but I find it understandable enough to consider it re-usable for my needs: // set class then add classes to first, last and even boxes. $class = 'blog_box'; if ($blog_entry->getItemKey($entry) % 2) {$class .= ' blog_box_even';} if ($entry == $blog_entry->first()) {$class .= ' blog_box_first';} elseif ($entry == $blog_entry->last()) {$class .= ' blog_box_last';} echo "<div class='$class'>"; echo "<p>Content here</p>"; echo "</div>";
    1 point
  11. I love love love this theme. But I'm very particular I've made a branch and simplified it a little further and changed things to my taste. Please feel free to fork yourselves. In short, I've disabled the animation, got rid of the sidebar and changed the fonts back to your standard Arial. Screenshots: http://cloud.alasdairmonk.com/472Y0B1k2r3Q1I472m0X/o http://cloud.alasdairmonk.com/1d1E2s2S2I1t2s163537/o Github Download: https://github.com/almonk/Al-s-Futura-PW-Theme
    1 point
  12. Yeah I think we probably should. Here they are. I've tried to tailor them for cheatsheet format and included an @advanced tag where applicable. I understand the sentences of text don't fit in the cheatsheet, so wasn't sure how you'd want to handle those (or leave them out), but put them here in case helpful. FieldtypeFile or FieldtypeImage can be configured to hold a single file or multiple files. When configured to hold multiple files, it is a WireArray (called Pagefiles or Pageimages) with these additions: <?php $files->path; // Returns the full server disk path where files are stored $files->url; // Returns the URL where files are stored $files->page; // Returns the $page that contains this set of files $files->delete($file); // Removes the file and deletes from disk when page is saved (alias of remove) $files->deleteAll(); // Removes all items and deletes them from disk when page is saved @advanced Each item in the WireArray is a $file or $image (called Pagefile or Pageimage). Likewise, when FieldtypeFile or FieldtypeImage is configured to hold a single file, it is just the $file or $image with the following properties and methods: $file properties <?php $file->url; // URL to the file on the server $file->filename; // full disk path to the file on the server $file->name; // Returns the filename without the path (basename) $file->description; // value of the file's description field (text). Note you can set this property directly. $file->ext; // file's extension (i.e. last 3 or so characters) $file->filesize; // file size, number of bytes $file->filesizeStr; // file size as a formatted string $file->pagefiles; // the $files array that contains this file @advanced $file->page; // the $page that contains this file @advanced (string) $file; // returns the file's name (no path) $file methods <?php $file->rename($name); // Rename this file to the given name (no path). Returns true on success, false on failure. $file->getNext(); // Returns the next file in a multi-file field, or NULL if at the end @advanced $file->getPrev(); // Returns the previous file in a multi-file field, or NULL if at the beginning @advanced When dealing an $image, it is the same as a $file, but with the following additions: $image properties (in addition to those in $file): <?php $image->width; // Width of image, in pixels $image->height; // Height of image, in pixels $image->original; // Reference to original $image, if this is a resized version. @advanced $image methods (in addition to those in $file): <?php $image->size($width, $height); // Return a new $image with the given dimensions (proportional, center crop) $image->width($width); // Return a new $image with the given width (proportional height, center crop) $image->height($height); // Return a new $image with the given height (proportional width, center crop) $image->getVariations(); // Returns a WireArray (Pageimages) of all size variations of this image. @advanced $image->removeVariations(); // Deletes all size variations of this image (be careful) @advanced
    1 point
×
×
  • Create New...