
pogidude
Members-
Posts
122 -
Joined
-
Last visited
Everything posted by pogidude
-
ahhh.. thanks @diogo.
-
actually, I found this: http://modules.processwire.com/modules/custom-page-roles/ .... which only hooked to viewable.. no editable and other code that is in the thread you linked to.. by the way the code by @apeisa in the thread would have worked for me.. On the upside, I guess we have another way of doing something
-
Just thought I'd share this module which I modified from the PageEditPerUser module by Ryan Cramer. I needed page-specific edit access by roles, not by user. So... Overview Assign edit access to roles on a per-page basis. Description The user must already have page-edit permission on one of their roles in order to get edit access to assigned pages. Otherwise, they will only gain view access. This module is fully functional as-is, but intended as a proof-of-concept for those wanting to go further with adding custom edit and/or view access. How to install 1. Copy the PageEditPerRole.module file to /site/modules/ 2. Go to Modules in the ProcessWire admin and click "Check for new modules" 3. Click "install" for "Page Edit Per Role" How to use 1. Create a new role called "editor" (or whatever you want to call it) and give the role "page-edit" permission. If you already have a role in place that you want to use, that is fine too. 2. Under "Access > Roles" locate the role you want to assign edit access to. Edit this role. 3. For this roles's "Editable Pages" field: select one or more pages you want users with this role to be able to edit. 4. Save the role. 5. Under "Access > Users" locate the user you want to apply the role to. Edit this user. 6. For this user's "Roles" field, select the new role you added - "editor". 7. Save the user and your are done. 8. To test, login as the user you edited to confirm it works how you expect. Download http://modules.processwire.com/modules/page-edit-per-role/
-
uh... not totally sure how I answered my own question there Sorry if I'm not too clear. In Ryan's answer, he has this: $this->error("error message"); $this->error("error message that only appears in debug mode", Notice::debug); one has Notice::debug, the other doesn't. On testing those two, the first one displays a message in the admin, the other doesn't. i've checked site/assets/logs/errors.txt and it wasn't there. So, where is it? Again, what exactly does Notice::debug do? and are there other flags that can be used?
-
If you do this: $this->error("error message that only appears in debug mode", Notice::debug); what does Notice::debug do?
-
Sorting page array containing pages without the sort field
pogidude replied to pogidude's topic in General Support
by the way, you may notice that I'm doing this: $without_speaker = $all_items->find('speaker<1'); instead of this: $without_speaker = $all_items->find('speaker.count=0'); I'm doing that because using count selectors (speaker.count) doesn't seem to work on PageArrays that have already been set. -
Sorting page array containing pages without the sort field
pogidude replied to pogidude's topic in General Support
Solved the problem. @wanze's and @diogo's ideas helped and I'm putting these below for anyone that might be looking of course improvements are welcome. $limit = 10; //we look for our desired pages with limit. this is to help with pagination later on. $items = $pages->find("template=talk|video,limit={$limit},categories={$page->categories},sort=speaker,sort=title"); /** * Get all items without setting limit. query will put items WITHOUT speaker in beginning of array. * But, we want items WITHOUT speaker to go to end of array after all the items WITH speaker field. */ $all_items = $pages->find("template=talk|video,categories={$page->categories},sort=speaker,sort=title"); //get items without speaker from $all_items $without_speaker = $all_items->find('speaker<1'); //filter out items without speaker from $all_items $all_items->filter("speaker>0"); //append $without_speaker to $all_items so that items without speaker go to the end of array $all_items->append($without_speaker); /** * Now we deal with pagination. Since we're showing $limit items at a time, we need to know which * page number we are and slice a PageArray of new items from $all_items accordingly */ $start = ($input->pageNum - 1) * $limit; $final_items = $all_items->slice($start,$limit); /** NOTE: Count of $final_items should match count of $items **/ /** * Replace the original items with our new items. * We do this because we want to use renderPosts() - from Blog Profile which outputs pagination * based on the given PageArray fed to the function. Otherwise, we could have just done the ff: * * $content = $final_items->render(); //or whatever render function * $content .= $items->renderPager(); //the pager is based off $items since that's the one with the limit */ foreach($items as $key => $item){ $items[$key] = $final_items[$key]; } //$content = renderMediaIndex($items); $content = renderPosts($items,true); include('./default-archive.inc'); one thing that could be improved is that double query in the beginning. I dunno.. just saying.. -
Sorting page array containing pages without the sort field
pogidude replied to pogidude's topic in General Support
sweet!!! I'll start off with @wanze's solution - which by the way was pretty close with what I was playing with but I didn't think about importing only if the $itemsWithSpeaker < 10 Thanks! -
Sorting page array containing pages without the sort field
pogidude replied to pogidude's topic in General Support
yes.. it now shows the pages with speaker field from Z-A (which unfortunately is not what I want), then the pages without the speaker field.. hmmmm.. how that *may* work.. how do I deal with the pagination? do it manually? can I feed a PageArray to renderPager() method? -
This is my selector: $items = $pages->find("template=talk|video,limit=10,categories={$page->categories},sort=speaker,sort=title"); echo renderItems($items); echo $items->renderPager(); the "speaker" field is a page type field and it is not required, so some pages won't have a value - null, or whatever it is for pages type fields. Now, the result would be sorted first by speaker - alphabetically - then by title. If the page doesn't have speaker, then it'll go on top of the array. Unfortunately, that's not what I want. I'd like the pages without the speaker field to go after the pages with speaker fields... Sorted by title. Is this possible with the api? p.s. I'm totally loving the api and the selectors. I love how I don't need to specify page ids or have to be very specific on my selectors.. it just freakin' works!
-
is there any documentation that I can look in to about the options that show up when you set $config->advanced to true?
-
ahhhh.. there it is thanks Ryan! @onjegolders - yeah saw $page->createdUser when I was searching in the forums but it wasn't what I was looking for. see the screenshot.. but thanks for the heads up
-
I installed the Blog Profile. After creating a blog post, you can go to the Settings tab of that blog post and see a "Created by User" field there. I'm just wondering how that got there? Coz I'd like to replicate it for another template. When I look at other pages using basic-page template or any other template for that matter, there is no "Created by User" field anywhere. I'd appreciate it if someone can point me in the right direction. Thanks!
-
never mind.. I found the reason inside `renderPosts()` function.. if(empty($page->summary)) { // summary is blank so we auto-generate a summary from the body $summary = strip_tags(substr($page->body, 0, 450)); $page->summary = substr($summary, 0, strrpos($summary, ' ')); }
-
Hi, I'm using the awesome Blog Profile and in site/templates/markup/post.php, there is this for displaying summary: echo "<p>" . $page->summary . "… <a class='more' href='{$page->url}'>" . __('View More') . "</a></p>" But when I edit the blog post or check the template used (post.php) I don't see any Summary field. is this field sort of automatic?
-
awesome!! thanks! by the way, where do I find a reference for all "wire('config')" and "wire('pages')" thing? or this a convention? $page, $pages, $config equal to wire('var')?
-
Hi, I'm trying to do the following inside a function: function register_styles(){ $url = $config->urls->templates.'styles/'; /** for working with google fonts **/ $fonts = array( 'Source+Sans+Pro:300,400,700', 'Dosis:400,700' ); $styles = array( 'google-fonts' => 'http://fonts.googleapis.com/css?family=' . implode('|', $fonts ) ,'bootstrap' => $url.'bootstrap.css' ,'base' => $url.'base.css' ,'structure' => $url.'structure.css' ,'design' => $url.'design.css' ); return $styles; } but I'm getting an error on this$config->urls->templates.'styles/'"Call to a member function add() on a non-object"thanks for helping
-
ahhh.. got it now. thanks!
-
When you go to Admin -> Setup -> Templates -> Edit "template-name" -> Access You see 4 permissions: 1. View Pages 2. Edit Pages 3. Create pages 4. Add Children I understand what 1,2 and 4 does. Not sure I understand what #3 does though. I've been trying to test and so far couldn't figure out what it does. What happens if I enable/disable this permission for a role? Thanks
-
+1 for the Starter Tutorial. It doesn't have to cover everything that PW can do. Just something that a new user or developer can follow and do in less than 10 minutes and get maybe a blog up and running.