Jump to content

Orkun

Members
  • Posts

    295
  • Joined

  • Last visited

Everything posted by Orkun

  1. How can I achieve a specific PHP-Selector in the "What PAGES should the Lister show?" section? Is this even possible? When yes how? Something like that: if($user->isSuperuser()){ $activitys = $pages->find("template=activity"); } else{ $activitys = $pages->find("template=activity, select_organiser=$user->select_organiser"); }
  2. I tried to echo $page on the select_multi_dates field. I get this: $page dont return the cast page, it returns the "Fredi - edit page process" page. How can I solve this?
  3. All Castpages are created under the activity: It looks like this: And the select_multi_dates field is on the cast template. So I thought i could get the current Activity with the casts parent and then access the items/pages from the activity_create_date pagetable. $currentActivity = $page->parent; return $currentActivity->activity_create_date; Unfortunately it doesnt work, I get this error: Fatal error: Call to a member function has() on a non-object in /Users/praktikant/Sites/Kulturdatenbank.pw.2.0/wire/modules/Inputfield/InputfieldPage/InputfieldPage.module on line 253
  4. I have a template called "activity" with two pagetable fields. Fields: activity_create_cast activity_create_date activity_create_cast: uses "cast" template for creating castpages. the cast template contains a pagefield called select_multi_dates. activity_create_date: uses "date" template for creating datepages. the date template contains a pagefield called select_activity. Now what i want is create a cast with activity_create_cast and I want that the selection of the select_multi_dates pagefield should be the pages wich i created before with the activity_create_date. How can I achieve this under the select_multi_dates pagefield with a PHP-Selector? I know its complicated PHP-Selector. Hope you can help me. Thanks for your attention. Nukro
  5. I think you want to add new Pages via the API? Here are some Threads: https://processwire.com/talk/topic/3105-create-pages-with-file-upload-field-via-api/ https://processwire.com/talk/topic/352-creating-pages-via-api/
  6. Hello everbody I want to make a autoload module that checks if the current page template exist, when not it should make a redirect to its parent page. I thought of something like this: public function init() { if(!$this->page->template->filenameExists()) continue; $this->session->redirect($this->page->parent->url); } My Problem is that when i add a Page via Fredi from the Frontend it redirects to a page that doesnt exist in the frontend. This is because I create Classifications Pages that have a template but not a template file because its not necessary in my case. I know, that i could just write in the templates something like this: $session->redirect($page->parent->url); But they are 8 templates that i have to create and write this and in my view that is unnecessary when i could achieve this only via a module. Thank you for your attention - Nukro
  7. You must use the else block. http://php.net/manual/en/control-structures.elseif.php <?php foreach($page->repeater as $box) { //if there are images uploaded output images if($box->images) { ?> <div class="box images"> <?php foreach($box->images as $image) { echo "<img src='$image->url'/>"; } ?> </div> <?php } else { //if not only output text ?> <div class="box text"> <?php echo $box->text; ?> </div> <?php } } ?>
  8. No one? The problem is that when I save the page, it redirects to the page that doesn't exist on the front-end because it has no template file.
  9. @RaymondGeerts @MartijinGeerts Thank for your answers. I have another question. At the moment I use Fredi module to create, read, update & delete stuff on front-end for every user. My users have the role "company" and i assigned a pagefield to the users template. Every user has an specific organiser(owner). So now what i am doing is when a user creates a new page/item they must also choose a organiser while creating the page. I filter the pagearray for every user by doing a check if the current page has the same organiser like the current user. With this approach he can only see the pages which has the same organiser like himself. This is for Overview pages: $pages->find("template=something, select_organiser=$user->select_organiser"); On the detail pages i check: if($user->select_organiser == $page->select_organiser || $user->isSuperuser()){ //continue } else{ $session->redirect($error404->url); } The PHP-Selector for selector_organiser pagefield: if(wire('user')->isSuperuser()){ return $pages->find("template=organiser"); } else{ return $pages->find("template=organiser, id=".wire('user')->select_organiser); } Users can only create/update|edit/delete pages with the organiser which the admin has assinged to him. The big Problem I have on this approach is that the users still can access the backend and then they can see/edit all the pages from the other users too. How can I hide the backend from the users? I can't give them only view-permission because of the Fredi module.
  10. Is it possible to delete and edit pages from the frontend? Because I know its possible to create pages via the API from the Frontend. Even when the user role only has view permission and not edit permissons. creating pages: https://processwire.com/talk/topic/352-creating-pages-via-api/ https://processwire.com/talk/topic/3105-create-pages-with-file-upload-field-via-api/
  11. I thought that i could bypass the problem, when I only give view permission to the users with the role "company" so that they cant access the backend. But the problem is then, that they cant create/update pages from the Frontent with the modal edit windows of fredi.
  12. Hello Processwire Community Lets say I have a Multi-User-System where I can create/update as "normal" user new events, dates, multimediapages, imagepages etc.... As Admin I can create organisers(owners) and assign them respectively to specific users. Module for creating/updating pages: Fredi - Friendly Frontend Editor Scenario: Add new Imagepage under Multimedia > Images Important Fields select_organiser(FieldtypePage)(btw. this field is assigned to the user template) PHP-Selector for "select_organiser" if(wire('user')->isSuperuser()){ return $pages->find("template=organiser"); } else{ return $pages->find("template=organiser, id=".wire('user')->select_organiser); } Templates image-index(is assigned to Image-Page) -> Fields: only title - > images-index.php Only show the image pages which has the same organiser like the current user. <?php $out .="<h3>$title verwalten</h3> <div class='span11'> <div class='btn-pos-1 add'>" .$fredi->setText("<i class='fa fa-plus'></i> Bild erfassen")->hideTabs("children|delete|settings")->addPage("image", "title|select_organiser", $pages->get(1153)). "</div> <table id='example' class='row-border' cellspacing='0' width='100%'> <thead> <tr> <th>ID</th> <th>Bildname</th> <th>Bild</th> <th>Beschreibung</th> <th>Veranstalter</th> <th>aktualisiert</th> <th></th> <th></th> </tr> </thead> <tbody>"; if($user->isSuperuser()){ $images = $pages->find("template=image"); } else{ $images = $pages->find("template=image, select_organiser=$user->select_organiser"); } foreach ($images as $i_item) { if($i_item->image){ $thumb = $i_item->image->size(50, 50); } $out .= "<tr> <td>{$i_item->id}</td> <td>{$i_item->title}</td> <td><a class='large_img' href='{$i_item->image->url}' ><img src='{$thumb->url}' /></a></td> <td>{$i_item->image_body}</td> <td>{$i_item->select_organiser->title}</td> <td>".date('Y-m-d', $i_item->modified)."</td> <td><a href='{$i_item->url}'><i class='fa fa-eye'></i></td> <td>".$fredi->setText("<i class='fa fa-pencil'></i>")->renderAll($i_item)."</td> </tr>"; } $out .= " </tbody> </table> </div>"; images(is assinged to children-items of Image-Page) -> Fields: title, image, image_body, select_organiser -> images.php At the beginnnig of the template it checks if the select_organiser of the current user is the same as the select_organiser of the current image page. <?php if($user->select_organiser == $page->select_organiser || $user->isSuperuser()){ $out .= "<h3>{$page->parent->title} Details</h3> <div class='span8'> <table class='detail-view table table-striped table-condensed'>"; $out .= "<tr class='odd'><th>ID</th><td>{$page->id}</td></tr>"; //get all fields: $all_fields = $page->fields; foreach($all_fields as $field){ if($field->type == "FieldtypeImage"){ $out .= "<tr class='odd'><th>{$field->label}</th><td>{$page->get($field->name)->url}</td></tr>"; } else if($field->type == "FieldtypePage"){ $out .= "<tr class='odd'><th>{$field->label}</th><td>{$page->get($field->name)->title}</td></tr>"; } else{ $out .= "<tr class='odd'><th>{$field->label}</th><td>{$page->get($field->name)}</td></tr>"; } } $out .= "<tr class='odd'><th>erstellt</th><td>".date("Y-m-d H:i:s", $page->created)."</td></tr> <tr class='even'><th>aktualisiert</th><td>".date("Y-m-d H:i:s", $page->modified)."</td></tr> </table> </div> <div class='span3'> <div id='sidebar'> <ul class='well nav nav-list' id='yw1'> <li class='nav-header nav-header'>Aktionen</li> <li><a href='{$page->parent->url}'><i class='fa fa-list'></i> Bilder auflisten</a></li> <li>".$fredi->setText("<i class='fa fa-pencil'></i> Bild bearbeiten")->renderAll($page)."</li> </ul> <br /> </div> </div>"; } else{ $session->redirect($error404->url); } The Problem of this System is that the user still can access to image-pages in the backend that dont have the same organiser. Its only view protected. So finally my Question: Can i specifiy a PHP-Selector for the editable pages for the Page Edit Per User Module. Like: return $pages->find("template=images, id=".wire('user')->select_organiser); So that the user can edit the image - pages which has the same organiser like him? Pagetree Structure and some screenshots of the interfaces for visualization: Pagetree Structure: Home(Login-Page) - Dashboard(Intro-Page) -- Events(visible for superuser and user with role: company) -- Agenda/Dates(visible for superuser and user with role: company) -- Multimedia(visible for superuser and user with role: company) --- Images(template: image-index) ---- example-img.jpg(template: image) ... --- Videos -- Profile(visible for superuser and user with role: company) -- Organisers(Only visible for Superuser) --- Organiser-Profiles ---- XYZ AG ... --- Adresses --- Locations -- Settings(Only visible for Superuser) -- Logout Image - Overview Page Image - Detail Page PS: Sorry for the long post
  13. How can I prevent the redirect when I add a new page with the Fredi Module? Here is my Code-Snippet: $fredi->setText("<i class='fa fa-plus'></i> $page->title erfassen")->addPage("user", "title|pass|email|roles|admin_theme|select_organiser|language", $pages->get(29));
  14. This should do the work: if(wire('user')->isSuperuser()){ return $pages->find("template=organiser"); } else{ return $pages->find("template=organiser, id=".wire('user')->select_organiser); }
  15. Hello Processwire Community Lets say i have a pagefield called select_organiser. The select_organiser pagefield is assigned to the user template and to the location template. Every User can create a location where he can set a organiser with the select_organiser pagefield. The Superuser can also create locations and he can assign a organisation to a user. No what i want is that the pagefield should check if the current user is a superuser, when yes he get a selection of all organiser pages. But when the current user is not a superuser he should get only a selection/select of the organiser that the Superuser has assigned to him. for example: organiser pages: organiser-example-1 organiser-example-2 organiser-example-3 organiser-example-4 ... users: test-user-1 test-user-2 ... Lets say I am the Superuser and i assign organiser-example-1 to the user test-user-1. Use Case: Create Location as Superuser I have a select with the selection: (organiser-example-1, organiser-example-2, organiser-example-3, organiser-example-4 ...) Use Case: Create Location as test-user-1 I have a select only with the selection: (organiser-example-1). This means I can only create Locations with the organiser: organsier-example-1. I hope you understand what i want to say/ask.
  16. Lets say i have a template with the following fields: title address_street address_additional_road address_zip_code address_place address_country address_email address_tel_1 address_tel_2 I want to output a table with the label of the field and the value of it. $out .= "<h3>{$page->parent->title} Details</h3> <div class='span8'> <table class='detail-view table table-striped table-condensed'>"; $out .= "<tr class='odd'><th>ID</th><td>{$page->id}</td></tr>"; //get all the fields: $all_fields = $page->fields; foreach($all_fields as $field){ $out .= "<tr class='odd'><th>{$field->label}</th><td>{$page->get($field)}</td></tr>"; } $out .= "<tr class='even'><th>erstellt von</th><td>{$page->createdUser->name}</td></tr> <tr class='odd'><th>erstellt</th><td>".date("Y-m-d H:i:s", $page->created)."</td></tr> <tr class='even'><th>aktualisiert</th><td>".date("Y-m-d H:i:s", $page->modified)."</td></tr>"; $out .= " </table> </div>"; In the foreach, it only outputs the title and I also get warnings: Warning: Illegal offset type in /Users/praktikant/Sites/Kulturdatenbank.pw.2.0/wire/core/WireData.php on line 41 Warning: Illegal offset type in isset or empty in /Users/praktikant/Sites/Kulturdatenbank.pw.2.0/wire/core/WireData.php on line 39
  17. I'm trying to achieve a specific selection for a pagefield for specific users. My pagefield should detect: If the current user is a superuser return all address-pages and when it's not a superuser, return all address-pages which the current user has created. It works fine for the superuser but i have no selection in all the other users. if(wire('user')->isSuperuser()){ return $pages->find("template=address"); } else{ return $pages->find("template=address, created_users_id=wire('user')->id"); }
  18. Solve the Problem: I had set the access of the organiser-template false. Only Superusers could access pages with this template. So the access to the organiser-template was denied for users with role company.
  19. I have the problem that i cant render a fredi link to a page which i choosed from a pagefield from a user. i have a user called "test-user". This "test-user" template has a pagefield called select_organiser which contains all the organiserpages. My approach: $organiser = $user->select_organiser; <li>'.$fredi->setText("<i class='fa fa-pencil'></i> Veranstalter bearbeiten")->renderAll($organiser).'</li> What I am doing wrong?
  20. Could you explain that further? How should I handle the two interfaces Admin and User? Do you mean for example: Login -Dashboard -- Veranstaltungen -- Agenda/Daten -- Multimedia -- Veranstalter -- Import/Export -- Einstellungen When the successfull login happens: if($user->isLoggedin()){ $session->redirect("./dashboard/"); } And then for exmplae i create a new event under Events and while creating i can choose from the pagefield which users i want. Then under the EventIndex-Template i list the events which has the selector like: if($user->isLoggedin()){ $events = $pages->find("template=event, select_users=$user->name"); foreach($events as $event){ //List the events with template = event and select_user = $user->name } } select_users is the pagefield with the selection of the users.
  21. How can i build multi-user-system for the frontend? I have an approach like: Pagetree: Login -Admin(Admin-Overview) -- Veranstaltungen -- Agenda/Daten -- Multimedia -- Veranstalter -- Import/Export -- Einstellungen -user-1(Overview) -- Veranstaltungen -- Agenda/Daten -- Multimedia -- Profil -- Benutzer -user-2(Overview) '' '' ... users: user-1, user-2 the users have the role: client When the successfull login happens: if($user->isLoggedin()){ if($user->isSuperuser()){ $session->redirect("./admin-overview/"); } else if($user->hasRole("client")){ $session->redirect("./$user->name/"); } } On the beggining of the _main.php where all the content will be loaded: To avoid access to the content from another user from the url. if($user->isLoggedin()){ if($page->name != $page404->name){ if($user->name != $page->rootParent->name){ $session->redirect("$page404->url"); } } } Am I on the right way or is this the completely false? Can you give me a better approach, a better, safer way to achieve a multi-user-system/management for the frontend?? I must migrate an existing Web-Application that was build with yii to Processwire.
×
×
  • Create New...