Jump to content

Soma

Moderators
  • Posts

    6,808
  • Joined

  • Last visited

  • Days Won

    159

Everything posted by Soma

  1. The code I posted would be in a autoload module. Instead of the init() it is the ready() because it's executed when the full API and page request is ready. If you have HelloWorld.module put that function inside just after the init(). When you have the module installed it's active and all users with "editor" role will get redirected to "/" if they try to access admin.
  2. Again, as I said in my previous post, if you give the user only view permission, they won't get into the backend. When they login through admin login you'll get a "continue" link that links back to the website. So without doing anything you already got those user from accessing the backend, but they still can use the admin login screen if they know it, but it's not issue at all. In one of a project I used this technic with a front end sign in and login http://muetterhilfe.ch/angebot/online-beratung/anmeldung/ Similar to what you say, I create a user page after they successfully registered, and save that in a page field on the user. After they login they get redirected to their page with a simple profil page and form to ask questions a expert then can answer. All the "permission" and handling is done without any permissions or special roles (just the user role with base view permission) just in the templates with absolutely basic API code. User's can't access other user pages, and this is simply done in the user page template, it checks if this really is the current user page. It all requires minimal coding and setup. It's so simple it's scary and often you think this can't be, but it is. When I find the time I'll maybe make a write up or simple profile that shows this simple setup.
  3. Only {$page->next->url} won't do anything you need php to echo out the variable. <?php ... ?> to let it know there's php code coming <?php // open php tag echo "<a href='{$page->next->url}'>$page->title</a>"; // end php tag ?> PHP will parse the {vars} if used inside double quoted "string" strings. Or <a href="<?php echo $page->next->url;?>"><?php echo $page->title;?></a> Or if server supports it there's a short notation <?= $page->next->url ?>
  4. Are there modules that manually installed and via modules manager short mm.. ?
  5. Roelof theres example I did for what you're looking for in that thread over therehttp://processwire.com/talk/topic/3868-pagearray-vs-explode/#entry37919
  6. Without knowing what script you use (custom built or downloaded) you could also add the image directly to the html and hide it. Then use it in you js and make it visible when you need it. Or you can add a data-url to a DIV tag and read that from the javascript. <div id="topimage" data-url="<?php echo $config->urls->templates . "img/top.png"></div> And in your javascript with using jquery var img = $("#topimage").data("url");
  7. I mean dev of the theme version just to make sure ;-)
  8. I develop it so I never have to change it. I never develop in a different structure than on dev and live... But if you do so and change root directory or have in a subfolder and on live not, you'll have to take care of image paths and link in PW anyway So one way is to pass the root path you can do so by passing it to js via a script in the header template. <script> var config_root = "<?php echo $config->urls->root ?>; </script> then in your .js files you can use var img = config_root + "site/templates/img/whatever.jpg";
  9. Yeah but still don't know where you're js lies and so can't say, but it's easy to make a relative path from your js to the image...
  10. It's in the dev version, you hover to show the actions...
  11. Has nothing to do with PW its in my theme. So yes.
  12. Try to find if you have the session folder there if not create one in assets.
  13. php doesn't work in a .js ...
  14. Why relative and not absolute from root? I have no idea what your js and setup is so I can't tell.
  15. To be honest I never use it cause in my teflon theme it requires only one click. :-D
  16. Why not create a custom login? The only reason to not give them admin access is if they're just front-end users. I wouldn't want my front-end user loging through processwire admin login. If you give the user no edit rights in roles they can't access the admin and get a "continue" link after login Even if you want them to manage content from frontend only I would take that route as the permissions can be defined on the fly in your temlates. The other way would be as kongondo mentioned, and here's a code you could put in a autoload module (like HelloWorld.module). ready() is used because it get's you access to all API. public function ready() { if($this->page->template == "admin") { if($this->user->hasRole("editor")) { $this->session->redirect("/somapge/"); } } }
  17. You can pay in EURO everywhere in Switzerland.
  18. Doesn't matter, I never used something else
  19. Don't know if you guys already recognized that you can now open a page in the page tree by double clicking the title. It's in since a couple months and I think, including me, didn't recognize it's there. Have a nice day!
  20. Yeah prev and next does only traverse inside a parent. But there's plenty traversal methods to get around it. $nav = ''; if($page->prev->id) { $nav .= "<a href='{$page->prev->url}'>prev</a> | "; } else if($page->parent->prev->id && $page->parent->prev->is("template=month") && $page->parent->prev->numChildren){ $nav .= "<a href='{$page->parent->prev->children->last->url}'>prev</a> | "; } if($page->next->id) { $nav .= "<a href='{$page->next->url}'>next</a> | "; } else if($page->parent->next->id && $page->parent->next->is("template=month") && $page->parent->next->numChildren){ $nav .= "<a href='{$page->parent->next->children->first->url}'>next</a> | "; } echo trim($nav," | "); Maybe need to adapt to your situation, but it's straight forward and everything is possible.
  21. <?php /** * Page edit per user created id * */ class PagesCreatedEdit extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'Pages created edit', 'version' => 1, 'summary' => 'Page edit only for created pages by user', 'href' => '', 'singular' => true, 'autoload' => true, ); } public function init() { // add edit permission hook for admin pages $this->addHookAfter('Page::editable', $this, 'editable'); } public function editable($event){ $page = $event->object; if(!$this->user->hasRole("editor")) return; if($event->return) { // only if edit rights are true if($page->created_users_id == $this->user->id){ $event->return = true; } else { $event->return = false; } } } } THis will get you there, not many different from frontend coding.
  22. I don't really understand as your code doesn't aswell. Ah now I get it sorry! What you're doing may a little inefficient to load all articles.
  23. But it's too long and cumbersome to type.
  24. Use $this or wire(). You can use fuel but Ryan once explained it's deprecated and an old artifact using it.
  25. PW already adds user id to page. You can get it with created_users_id... or something like this.
×
×
  • Create New...