Jump to content

Soma

Moderators
  • Posts

    6,798
  • Joined

  • Last visited

  • Days Won

    158

Everything posted by Soma

  1. Thanks nik. No Markup Cache isn't installed. I also deleted caches, no luck. Don't know about APC if that's even running on that hosting.
  2. My DataTable process module would be a good place to start. I've shared it mostly for others to use as a base. It's not a finished complete product, but more of a proof of concept. Since the needs are always different it's hard to make such a module work for all cases. I'm using a modified version on a online shop with hundreds of products. It's easy to change what cols are output and adding filtering by templates or categories. If you are comfortable a little with php and js you'll figure it out, or just ask away in the forums if you need help.
  3. Ok, when I have php 5.3.8 with latest dev. I can't login and get this error on login page (login form isn't visible) Compile Error: Can't inherit abstract function ConfigurableModule::__get() (previously declared abstract in WireHookable) (line 32 of /[removed]/wire/modules/Markup/MarkupCache.module) When I set php to 5.4.10 it works again.
  4. That also mean from now on PW doesn't work with prior php 5.3? I updated PW and got an error, but nothing logged or indicating what the error is. I finally also updated to php 5.3 and installed fresh PW and it now works. I'm also for going forward and php 5.3+ is cool, but there's some hostings that still run ~5.2 and I won't be able to update from now on, until they update php. Edit: just seen my hoster has updated and I can run php in 4 different versions.
  5. If the /faculty/ template does have access rights set, yes then it wouldn't work as you get the page explicitly with get("/faculty/"). But for children when I remove view access for a role they won't show up in navigation unless you explicitly check the option to show them in lists and searches.
  6. I would keep the structure flat and use date sorting. Moving posts from a "show on front" place to a "archive" place is most always not a good idea, in PW the structure is reflected in the URL and the URL of the post will change. So if someone linked to the post it will break (though there's a module that solves the issue with url redirects but it's questionable). To have an archive state for a post defined by a structure, where you have to move pages around, is something I would avoid generally. Having content live in a /archive/post1/ structure is always questionable, and if choosing to design such urls it would be done soft using urls segments. In your scenario I would keep the structure "flat" of the posts and if you want to define posts that show up on a up-front page, use a page field to select and sort them. Then render this page list out.
  7. In the modules forum. Too lazy to link to on mobile.
  8. Speaking of images manager each image is a page.
  9. Use page fields and youll be able to select a page image or a parent or multiple. ImagesManager doesnt restrict but help.
  10. I always start blank and do my custom css with some exceptions. For me layouting is easy once you know the ins and outs and css frameworks mostly just get in the way for my needs. And for special things and micro layouts they never provide what I need anyway. That of course is from a guy who does website layouts since over 15 years.
  11. The CustomPageRoles module is alpha, proof of concept and it says that pages still will be rendered in navigation. You'd have to exclude them when cycling the pages in the loop with $page->viewable(). But implementing this check in the modules manager would get kinda complicated and result in some potential problems with how it all works together. The MarkupSimpleNavigation is access aware, but CustomPageRoles doesn't exclude pages when using with find() or children() calls, that's why it doesn't work also with MSN (heh). You can do use page_roles (page field) to do what you want with a simple check for user roles simply with this: echo $treeMenu->render(array("selector" => "page_roles={$user->roles}")); Because of the use of a selector you have to add and define page roles for all pages you have in navigation. It's not using the viewable access method, but simply checking the page field for if any of the user's roles is added.
  12. No no, I meant that maybe this Module is the problem.
  13. Do you have ChromePhp logger installed?
  14. If youre logged in youll see also unpublished pages?
  15. I haven't tried and I don't thin it would work just out of the box, but it would be easy to adapt it to use in front-end. You only need the js script to be added and run the execute like $dt = $modules->get("DatTable"); echo $dt->execute();
  16. No it's 2.3 compatible, but every new version has a new checkbox to check and I haven't done it yet. I think there's many modules that suffer from this.
  17. You could also add a password field to the admin template.
  18. Password field is not made for uae like this. Module config stores json array. But password needs to be a field on a page as it stores pass and salt. Also when using like you do you only use the inputfield and not the fieldtype which encrypts the data. You may consider using a page to store.
  19. I often listen to this kind of music while my fingers are dancing on the keyboard..
  20. Yes helper functions like this can be included using a separate php like in the head.inc and used throughout your templates. I extracted this function from a module I have for a project. This module has various helper function and then I load it in the templates. It's much the same as if I would include a php with functions and just personal preference. For example: $helpers = $modules->get("TemplateHelpers"); then use it like this where I need it. echo $helpers->wordLimiter($page->body); I'm not sure what you mean by applying the function to the body. I use this function to create teaser texts that are limited, and show the complete body only on the detail page. Of course you could modify the body output, that every time you do an echo $page->body, it will run it through a function, but I'm not sure this is a good practice. This using a hook on the formatValue of textfields would do it: (directly in template like a include, or by making it a module) function wordLimiter(HookEvent $event){ $field = $event->argumentsByName('field'); if($field->name != 'body') return; $str = $event->return; $limit = 150; $endstr = ' …'; $str = strip_tags($str); if(strlen($str) <= $limit) return; $out = substr($str, 0, $limit); $pos = strrpos($out, " "); if ($pos>0) { $out = substr($out, 0, $pos); } return $event->return = $out .= $endstr; } wire()->addHookAfter("FieldtypeTextarea::formatValue", null, "wordLimiter"); // now this will trigger the above hook echo $page->body; But it's a little cumbersome, as you can't set the limit. Also this strips tags and on HTML text you'll lose formatting. But just to show adn example what is possible. From your post I guess you like to do something like: echo $page->body->limit(150); // not possible It's not possible to do this, because the $page->body, body is just a string and not an object you could add methods to it. But something like the following would be possible using hooks. echo $page->wordLimiter("body", 120); You can use addHook to add a method wordLimiter to page: function wordLimiter(HookEvent $event){ $field = $event->arguments[0]; // first argument $limit = $event->arguments[1]; $endstr = isset($event->arguments[2]) ? $event->arguments[2] : ' …'; $page = $event->object; // the page $str = $page->get($field); $str = strip_tags($str); if(strlen($str) <= $limit) return; $out = substr($str, 0, $limit); $pos = strrpos($out, " "); if ($pos>0) { $out = substr($out, 0, $pos); } return $event->return = $out .= $endstr; } // this will add a custom method to Page object wire()->addHook("Page::wordLimiter", null, "wordLimiter"); // now you can do this echo $page->wordLimiter("body", 100); // or this echo $page->wordLimiter("summary", 100);
  21. If you have latest LanguagePageNames, and you have set the home/root page the names "en", "de" and "fr"...? You can access the root name through the root page name. $lang_segment = $pages->get("/")->name; From anywhere in you templates no matter what sub page. But maybe with this setup isn't really save, if you don't have those names set or the default would have no segment name, it's not as reliable to assume it is set. But you could get around it. Better you just get the current user language in the front-end, since this is automaticly set by the language names module. This will have the language name that is set in the language support. Since default name can't be changed you have to get it like this to set default language code. $langCode = $user->language->isDefault() ? 'en' : $user->language->name;
  22. <?php class PageEditFoldStatus extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Page Edit Fold Status', // printable name/title of module 'version' => 0.1, // version number of module 'summary' => 'Uses cookie to remember fold status of fields on page edit', // 1 sentence summary of module 'href' => '', // URL to more information (optional) 'singular' => true, 'autoload' => true ); } public function init() { $this->addHookAfter('ProcessPageEdit::execute', $this, 'hookPageEdit'); // make sure we the request is from backend as ProcessPageView is used for all page views if(strpos($_SERVER['REQUEST_URI'], $this->config->urls->admin) !== 0) return; $this->addHookAfter('ProcessPageView::execute', $this, 'triggerScript'); } public function hookPageEdit() { $class = $this->className(); $this->config->scripts->add($this->config->urls->$class . "js/jquery-cookie-master/jquery.cookie.js"); } public function triggerScript(HookEvent $event) { // only go further if we are on page edit process if($event->process != "ProcessPageEdit") return; $script = <<< _END <script type="text/javascript"> //...JS code... </script> _END; $event->return = str_replace("</body>", $script . "</body>" $event->return); } } This should do it. Forget about ModuleJS. Jquery core script is added in the admin.php process controller, so if you use ModuleJS or an init function of a Wire Module it will always get added before jquery core. So only way to add is through an autoload module with a hook on a other process or inputfield module. To render a script into the html, you need a hook to something that returns some rendered markup. Then inject it with a str_replace. Or you could hook into the ProcessPageEdit::buildForm and append a InputfieldMarkup with the script as the content, that will then get rendered with the form. Edit: changed Wire to WireData and added check to only add hook if on a backend url
  23. willyc, nope. it's not in modules directory yet!
  24. I think you mean something like this: function wordLimiter($str, $limit = 120, $endstr = '…'){ $str = strip_tags($str); if(strlen($str) <= $limit) return $str; $out = substr($str, 0, $limit); $pos = strrpos($out, " "); if ($pos>0) { $out = substr($out, 0, $pos); } return $out .= $endstr; } echo wordLimiter($page->body);
×
×
  • Create New...