-
Posts
6,808 -
Joined
-
Last visited
-
Days Won
159
Everything posted by Soma
-
Thanks a lot Ryan, after your previous post it ringed a bell I forgot that on first level there's only ressort-page and some others allowed, but I did test with sub-page template access settings which isn't allowed there so that's why. Stupid me really.. I should have found out myself. You're right. Sorry for bothering you for something simple.. maybe I should sleep a little more.
-
If you want to take a look at it, it's on the dev install I've sent you thru PM... you could see it yourself. There's also a editor/editor1 login you could test.
-
Edited my post, I deinstalled the module and it still not working on that root branch page like "/de-de/". SO it doesn't matter on the module. Though the additional "create" pages on template role setting seems to work, just not on that one to add new children. Don't know what's going on. I just can say... worked well before the update... PS: I don't understand you suggestion with the return, as it's working well as it is.
-
Awesome, thanks Ryan for considering and reactivating this. I just pulled the latest and I see there's the option and it seems to work so far. Only problem I got now is that for the language tree branch I have a template for the branch "/de-de/" and I've set it via page references in the user template to be a working space, so all pages in this branch can be edited by the editor role. I have a module for this, where it looks for if pages are in the branch the user has defined. I've set it up so they can't edit the "/de-de/" page but add "new" pages. For some reason after the update there's no "new" action anymore, only on subpages, although I have set the template to allow add pages. Even If I add "edit" permission there's still no "new" action. Here again the code (already posted on multiple thread) I use for the user workspace <?php public function init() { if($this->user->hasRole("editor")) $this->addHookAfter("Page::editable", $this, 'checkpermission'); if($this->user->hasRole("editor")) $this->addHookAfter("Page::addable", $this, 'checkpermission'); //if($this->user->hasRole("editor")) $this->addHookAfter("Page::listable", $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; // root node access granted //if($page->url == "/") return true; // run check for parent pages and allow recursive inherit access foreach($parents as $p){ if($this->user->editable_pages->has($p)) return true; } // then run check on selected single pages if(!$this->user->editable_pages->has($page)) $event->return = false; } EDIT: I just deinstalled the module and it doesn't change anything. Strange, the template has add children permission set on the editor role, though they can't add children pages to it...
-
That would be great to have such an option when resizing images. BTW shouldn't we put that image stuff in the cheatsheet for reference?
-
That's good idea. I think there will be a need for some manifest file or alike in the future. Especially when there will be some sort of package installer, and also to avoid complications/conflicts I thought about having some unique key/namespace that would be registered. I think modx has this for their package management.
-
You can by using 0 for the side you want to auto scale. I think I've seen another way with using null. Also you can use ->width(100) or ->height(n) respectively doing the same as keeping the ration either on width or height While at it, Ryan how is the compression setting when using API to scale? Is there way to set it?
-
How to show a list of children, grouped by category title?
Soma replied to MarcC's topic in General Support
if you have your categories as pages under a page /categories/ you could loop them and output examples having this category. In this example we assume "category" is the name of the page field in your sample. <?php // get all categories $categories = $pages->get("/categories/")->children; echo "<ul>"; // loop categories foreach($categories as $cat) { echo "<li>{$cat->title}"; // find me all samples having the current category $samples = $pages->get("/music-samples/")->find("category=$cat"); // if any found output them if( count($samples) ) { echo "<ul>"; foreach($samples as $sa) { echo "<li>$sa->title</li>"; } echo "</ul>"; } echo "</li>"; } echo "</ul>"; ...accidently submited before finishing code -
Yeah, I'll make the animation of the advanced toggle faster, just simply forgot about it to make it as fast as the other slide animations. Thanks fro mention it diogo. I'm pretty much with ryan here, after all I think it does fit better on bottom of the list.
-
How to save submitted form data from a module
Soma replied to evanmcd's topic in Module/Plugin Development
I think you're trying to save a value to a page field. You can simply use $page->fieldname = 10; $page->save(); Have you looked at the topic http://processwire.com/talk/index.php/topic,262.0.html for a simple poll using pages here? -
It's there already
-
Hey statestreet, congrats on your album and cool site there you got! Thanks for sharing.
-
Congrats, you just opened a big new magic box there! Have fun
-
I thought this should work, but not sure why you want to get page by process. I now there's $page->process to get but why can't you just use name? Do you have multiple pages with the same process? Maybe possible to use a prefix in the name and do a search "name^=prefix" to get all. ?
-
Ah, yeah I think that's what I'm looking for. page-add permission. I was a bit confused to why it isn't there. So I went over it again where my main problem was and where I thought about having this option. It would be for pages I want to give the editor rights to edit but not add new pages with it. But when I give edit permission, it shows up in the template select. I agree that we should keep this access things as straight and easy as possible, but such an option would greatly help and not add too much complexity. Though I was already a little confused not really because it's complicated but because I haven't slept much for a long time . I really would like to have this out of the bo, maybe not installed but there in the package. Yeah I'll be glad to give you access though PM. So only if you like, you don't have to. As I mentioned most templates are for having flexibility, and most are purely there for structuring. I know there would be different ways to archive the same, and have the logik in templates using let's say ID's or paths instead based of template name. I just think the ability to structure the templates with something like "tags,categories" could help to reduce the template list to what you're looking for. I think this can come in handy too when dealing with large sets. I know there's filters, but they're not the same.
-
You can just use: $articles = $pages->find("category=$page, limit=50"); The $page is the current category page, which serves also as the catergory page to select in the articles. So category is a page reference field on the article pages. Also you could use template with urlSegments enables to setup a page "categories" that lists pages from a category, you can use like: /categories/categoryname/ Then use something like this: $cat = $sanitizer->pageName($input->urlSegment(1)); $articles = $pages->find("category=$cat, limit=10"); Edit: Sorry corrected some in the code, its $input->urlsSegment() not $page->urlSegment(). And $sanitizer-> not $page->sanitizer
-
I think what you experience is what we got in this thread http://processwire.com/talk/index.php/topic,558.0.html It's basicly the problem that the jquery ui datapicker date format isn't compatible with php date format. I spent some time to do a mapping array for converting (as you see at the end of the thread) , but ryan hasn't implemented it yet. I think it would work with simple dates, but not for times. I'm not sure how well this can be implemented for datetime fields and datepicker with time select addon).
-
A different way of using templates / delegate approach
Soma replied to Soma's topic in API & Templates
Great to see and know we kinda got same spirit here, you also seem to use similar approaches! Should have posted that earlier, I think it's pretty much needed this kind of threads sharing ideas. As with other parts of PW that still seem to be undiscovered for some people. (was surprised some people here didn't knew there were a tabfield they could use). Not that I think is a problem, but maybe we should start getting/pointing those things out more, even if it's just in threads like this. Back to the template thing. I also use main.php with basic html frame with head and body, and maybe a div wrapper, and the page template includes some structure that is different from page to page layout, though still it's enough flexible to extend and based on variables or template do different things like sidebars. I'm also trying out to use it the other way round much like your's Ryan. Also having structure and data more separate can help a lot. While I'm still using the echo "<p>$somevar</p>" quite a lot now in PW, I think it's not really the best way to build. Mixing php and html can lead to messy code and cluttered, noisy, harder to maintain. I'm strictly going down that road now again and still thinking about different approaches. A template parser would be handy but can create some limits at best and it's slower at the end of the day. - The other day I was trying to code one simple module to use for blog/news type listing, just for fun. Mainly to try out coding a tag parser, and ended up with the plain php and the template parser approach right in front of me, and the knowledge creating this yet simple but hard to still programm little module. I came to the conclusion, that I still prefer pure php since it can do the same with a little more code but be alot more flexible to me. – But still I'm also thinking it could simplify some tasks, and maybe still be useful to the less experiences php newcomers. It would be easy possible within PW to create markup-generating type of modules. Not sure If that should be done, as It's a little against PW's philosophie. But I really like pre-created profiles! As mentioned also in another thread, I think this could get possibly a big thing. I like the idea of having ready to go installs, and you Ryan already created the tool to export site profiles. Best part of it It can help some newcomer peoples so much, I think this should be considered quite important thing we should ignite as soon as possible. Well not trying to push things. I'm sometimes really impatient when something new excites me. -
Yeah Nico, because I loaded the latest commit... but I meant the "site" link overlapping navigation.
-
-
Yeah, glad you like the module and even have added things! - Though I don't see the benefit of seeing 10/5 that much but nice touch. - To see the installed ones on hover. How would this look with the 30 Fields? I thought it's nice but not something I would want really. But don't hestitate to make adaptions to your likeing. You could fork mine on github and let other people use it?
-
I found (after 2-3 Projects using PW) that it's a good technique to use templates in a way I think hasn't been thought of yet really by some. (Although the CMS we use at work for year, works this way.) I'm sure I'm maybe wrong and someone else is already doing something similar. But I wanted to share this for everybody, just to show alternative way of using the brillant system that PW is. Delegate Template approach I tend to do a setup like this: - I create a main.php with the main html markup, no includes. So the whole html structure is there. - I then create page templates in PW without a file associated. I just name them let's say: basic-page, blog-entry, news-entry... but there's no basic-page.php actually. - Then after creating the template I make it use the "main" as alternative under "Advanced" settings tab. So it's using the main.php as the template file. - This allows to use all templates having the same php master template "main.php" - Then I create a folder and call it something like "/site/templates/view/", in which I create the inc files for the different template types. So there would be a basic-page.inc, blog-entry.inc ... - Then in the main.php template file I use following code to delegate what .inc should be included depending on the name of the template the page requested has. Using the TemplateFile functions you can use the render method, and assign variables to give to the inc explicitly, or you could also use just regular php include() technic. <?php /* * template views depending on template name * using TemplateFile method of PW */ // delegate render view template file // all page templates use "main.php" as alternative template file if( $page->template ) { $t = new TemplateFile($config->paths->templates . "view/{$page->template}.inc"); //$t->set("arr1", $somevar); echo $t->render(); } <?php /* * template views depending on template name * using regular php include */ if( $page->template ) { include($config->paths->templates . "view/{$page->template}.inc"); } I chosen this approach mainly because I hate splitting up the "main" template with head.inc and foot.inc etc. although I was also using this quite a lot, I like the delegate approach better. Having only one main.php which contains the complete html structure makes it easier for me to see/control whats going on. Hope this will be useful to someone. Cheers
- 83 replies
-
- 27
-
-
I just updated the sheet. - added fix to menu when scrolling - moved some entries to advanced mode - added toggle button on sections - minor changes Hope it still works well for you guys.
-
Thanks Ryan for the answer. Well the setup of the templates so far work fine regarding access and family. I use it inheritely and am using the family settings sparely and only for allowed childs. I played around with it quite a lot. But what I'm requesting is not this, my idea is to be able to say "this" template is only allowed to be selected (when creating a new page) by a certain role. So that templates only I should be able to select aren't visible to the editor when creating new pages. For example a special form-template. So while I could make it not to be in the allowed family of one or another template, I would need to add it temporarely, just so I am able to create a page with it. Hope you understand what I mean. I got that many because it demands that many (I was already cautious on not having too much), and they're not all for pages only. Some are for folders, different types of page elements (as childpages, guess this will get better once we have repeatable, flexible elements on page), some ar for different types of downloads (also as pages) and download folders to be able to select them and have all downloads listed from that folder. There no way to do it different or with less templates. While It was my first big, more complicated and multilangauge project with PW, I think some could be simplified. But I already got a main sub-page template which is used for the majority of page thoughout the site and has many fields and tabs for different elements, to keep it flexible and not create a template for each type of page. Edit: I understand your suggestion to make this kinda work on a per role/template basis, but it's not practicable in my setup. May if you want I can give you acces to the site, so you could take a look?