Jump to content

slkwrm

PW-Moderators
  • Posts

    321
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by slkwrm

  1. Hi, guys. I need your help with my firs very basic module (the code is below). So here go my questions: 1) I want to place this links on the left from submit button. The thing is I can't do this with PHP because jquery script modifies the page after it's loaded (for ex. the bottom submit button is copied by jquery script to the top). So I'm not sure how I should handle it. I suppose using additional jquery script wich adds my links, but I don't really know how to do this. Should I use $this->script->add? Is it right to extend ModuleJS in this case instead of WireData? Where should I hook to inject my jquery? For now the links are placed for testing purpose near the logo at the top. 2) I can't get it working on the module edit pages and I don't know why. I think maybe it's because of the find() method is overriden in Modules class. I commented this part. 3) Is it the code too ugly and this could be solved using just a one-liner? Not so much related questions: 1) Wouldn't it be better to initially generate admin pages using php and let jquery only init classes of elements, so that when a page is hooked after rendering it has more predictable structure. Is it possible at all, or maybe I'm overcomplicating things and there is an easier way to handle this problem? 2) Does anybody uses 3rd party libs to handle DOM manipulation or just DOMdocument and Xpath? Thank you in advance. I'm going to go sleep now so won't be able to discuss it in the nearest hours <?php class PageNextPrevLinks extends ModuleJS implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'Page Next Prev Links', 'version' => 101, 'summary' => 'This module places next and prev links in a page\'s editor if the page has siblings.', 'href' => 'http://www.processwire.com', 'singular' => true, 'autoload' => false, ); } public function init() { if($this->user->isGuest()) return; $this->addHookAfter('Page::render', $this, 'addLinks'); } public function addLinks($event) { //get current page $editpage = $event->object; //if it's not one of the edit pages then exit //if(!in_array((string) $editpage->process, array('ProcessPageEdit', 'ProcessTemplate', 'ProcessField', 'ProcessLanguage'))) return; $adminUrl = $this->config->urls->admin; $siblings = New PageArray(); if ($editpage->process == 'ProcessPageEdit') { $page = $this->pages->get($this->input->get->id); $siblings = $page->siblings("include=all"); $adminUrl .= 'page/'; } elseif ($editpage->process == 'ProcessTemplate' && isset($this->input->get->id)) { $page = $this->templates->get($this->input->get->id); $siblings = $this->templates->find(''); $adminUrl .= 'setup/template/'; } elseif ($editpage->process == 'ProcessField' && isset($this->input->get->id)) { $page = $this->fields->get($this->input->get->id); $siblings = $this->fields->find(''); $adminUrl .= 'setup/field/'; } elseif ($editpage->process == 'ProcessLanguage' && isset($this->input->get->id)) { $page = $this->languages->get($this->input->get->id); $siblings = $this->languages->find(''); $adminUrl .= 'setup/languages/'; } elseif ($editpage->process == 'ProcessUser' && isset($this->input->get->id)) { $page = $this->users->get($this->input->get->id); $siblings = $this->users->find(''); $adminUrl .= 'access/users/'; } elseif ($editpage->process == 'ProcessRole' && isset($this->input->get->id)) { $page = $this->roles->get($this->input->get->id); $siblings = $this->roles->find(''); $adminUrl .= 'access/roles/'; } elseif ($editpage->process == 'ProcessPermission' && isset($this->input->get->id)) { $page = $this->permissions->get($this->input->get->id); $siblings = $this->permissions->find(''); $adminUrl .= 'access/permissions/'; } //TODO can't get it working, throws an error /*elseif ($editpage->process == 'ProcessModule' && isset($this->input->get->name)) { $page = $this->modules->get("{$this->input->get->name}"); $siblings = $this->modules->find(''); $adminUrl .= 'module/'; }*/ $out = ""; //generate next & prev links output if (count($siblings)) { if (($prev = $siblings->getPrev($page)) && $prev) { $out .= "<a href='{$adminUrl}edit/?id={$prev->id}'>< prev</a>";//« prev</a>"; } if (($next = $siblings->getNext($page)) && $next) { //$out .= $out ? " • " : ""; $out .= $out ? " | " : ""; $out .= "<a href='{$adminUrl}edit/?id={$next->id}'>next ></a>";//'>next »</a>"; $out .= $next->id; } if ($out <> "") $out = "<div class='NextPrevLinks'>".$out."</div>"; } $event->return = str_replace('<p id="logo">ProcessWire</p>', $out.'<p id="logo">ProcessWire</p>', $event->return); return $event->return; } }
  2. Very cool photos, statestreet. Really like "Play Dead" and "Damen". Site looks nice and clean and I like it. The only thing that bothers me is a "nervous" sidebar
  3. I updated my previous post but the topic didn't show up in new content, so just wanted to up my post by this. If anybody knows a better way to update the first post, please let me know and sorry for double-posting.
  4. Wow! Congratulations, Pete. The site looks great!
  5. If I understand your need correctly, you can achieve the same result using: $limit = 5; $pageslice = $page->children("limit=$limit"); $total = count($pageslice);
  6. Great update, Ryan! Subtle changes like this gradually push PW closer towards being ideal CMS/CMF. Very useful and needed additions.
  7. I think the code can be improved using: $out = preg_replace('/\s+/', ' ',$out); instead of: $out = strtr( $out, array( ' ' => ' ' ) ); as the first variant will substitute even multiple spaces (more than two).
  8. Please, correct me if I'm wrong, but I think that $page->parents->isValidItem($child) only checks wether $child value is an instance of a Page class. And $page->parents->has($child) makes sure that $child value is among the $page's parents.
  9. Hey Digitex, check this out! This brand new feature makes creating sections a breeze even for dumbest users alive And it works with all your favorite page inputfield flavours. Update now and get it absolutely free of charge!
  10. Welcome, Charliez Hehe. It seems like you are coming from MODx realm, right? You don't really need to do it in PW the way you did it in MODx. I think what you mayby need is pages serving as building blocks, so that you can choose what blocks you want to use on your page and then just call them to render themselves in your template. Maybe it sounds a little complicated at first, but it's really easy after you've wraped your head around PW's philosophy. And yeah, storing php in fields is evil
  11. Thanks! I must be blind or something Don't know how I managed to do such a weird mistake.
  12. Try to do this (written in browser): $spring_courses = $pages->find('parent=/courses/spring/')->has('course_instructors=$page'); Just realized it's totally wrong. Sorry for disinformation. Please, use Soma's method.
  13. I'm not sure, but maybe size() function isn't chainable. Try to do this, maybe It will help: $thumb = $tdobject->icon->size(40, 40); echo '<td><img src="'. $thumb->url . '"/></td>';
  14. Guys, I've got a trouble with TinyMCE inputfield. When I use my translation file for it the field just stays textarea doesn't turn into TinyMCE. I put here the the translation file that causes trouble (changed file extension to .txt to allow upload). Thank you. wire--modules--inputfield--inputfieldtinymce--inputfieldtinymce-module.txt
  15. Welcome, Everfreecreavtive. I have to say, my thoughts were very similar to yours when I found this great CMS (and great community). I was very frustrated in my quest of simplicity in CMS scripts. When I found it I was amazed how simple yet powerful it is. Actually, I still can't fully believe that this CMS is a brainchild of one man It's too good to exist, but you're not dreaming. Just remembered (using google ) a good quote of Einstein on the topic: Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction.
  16. I'm not sure, but think that you have to make a page for this purpose with a dedicated template and then include your php-script in this tempalate. And call that page from your js. You can use additional URL-segmants or set POST variable to check before running your included script. I think this way it should work.
  17. We had similar thoughts about it a couple of days ago here
  18. Well, maybe you shouldn't tell your users categories are pages The page in PW is very close to a "node" consept in Drupal. Users, roles, permissions are actually pages. And having such a powerful tool like custom fields (aka fieldtypes) at your command you can create any kind of pages which can serve very different purposes going far beyond traditional usage. And thanks to great API you can get all the data from that pages' fields very easily. This could be the case but not sure where to start. What would that page need to output? Some text string or array or straight up html form with checkboxes? The key point here is to understand what are templates in PW. When I just registered here on forums I didn't quite uderstand what it was. I'll quote Apeisa's answer which he PM'ed me back then, 'cause it's short and comprehensive: Using $page and $pages API-variables in your template file you can get and then output any data you want and the way you want it. PW doesn't output any markup (but in some cases it provides reasonable defaults, e.g. for pagination), so it's up to you what's on your page and how it looks. I heard many good things about EE, but I'm not familiar with it. I think there are people here on forum with some EE background, who can draw some analogies or compare PW with EE. After you've read all the documentation pages on the website, try to use forum search to find many ready-to-use recipes, since all the most typical questions has already been answered (try to request breadcrumbs, template, pagination etc.). Also I recommend you to add Soma's brilliant Processwire cheat sheet to your bookmarks, it will save you a lot of time. Here is an interesting thread about some advanced tips regarding different aproaches of templates organization. Also check out this thread, may be helpful as w(h)ell . P.S.: As far as I know Ryan can send you skyscraper site profile on request, try to PM him about it. Hope it helps. Cheers.
  19. Biotech, I think you can safely use this approach. Not sure though wether you need both categories and subcategories. If it's a personal blog I think it can be a little bit of overkill. I would just create one level of categories, and if it's not sufficient I would add tags. But it's my very personal point of view And if you are dealing with huge multi-user blog with a lot of articles, this structure is the way to go. As for checkboxes. I think you might create a dedicated template and use it for your sub-categories aka pages. Then you could use an option in your field settings to set selectable pages by the template they use and not by their parent. Is it what you need? I'm not sure how it's done in Wordpress, but I think you can have it even better with Processwire, because you can always code your own Inputfield the way you want or customize already existing. If you worry that PageListSelectMultuple can't handle big number of pages - just don't! I think Ryan could explanain how it's all optimized to work with hundreds or maybe even thousands of pages
  20. Hi, biotech and welcome! Actually, despite you can choose a page twice or even more times using PageListSelectMultuple, after you save the page all the duplicated pages will be gone as it allows to have the same page only once.
  21. Soma, I just installed your theme and I've got some points for you: 1) I see this site link at the bottom. I don't think it ment to be there. (FF & Chrome). 2) Translation labels don't show up in the top menu and in breadcrumbs, everything's still in English. 3) The same thing with logout and profile links. 4) I'm not sure it's the problem of the theme, but there's no margin between MapMarker's input fields. 5) The width of the top menu's dropdowns is too big for my liking, I would make it shorter Cheers!
  22. Thanks, Soma! Looks pretty cool. I'll test it as soon as possible.
  23. Ryan, could you eleborate a little bit more, what are the do's and don'ts for repeatable fields?
  24. Child pages as building blocks for versatile layouts? Sounds cool! Can imagine how I could pimp some landing page using it. With repeater fields it must be very easy to do (and I think Ryan mentioned nesting capabilities!). The only thing that's missing to make workflow really handy is, as Pascal said, a possibility to create new pages (building blocks) instead of just being able to select them. I guess it's possible to implement this feature with a module, though I don't know how hard it would be, Definitely not too easy, as it would require good knowledge of PW internals and (am I right?) some ajax magic.
×
×
  • Create New...