-
Posts
344 -
Joined
-
Last visited
-
Days Won
1
Posts posted by fbg13
-
-
I'm trying to create a site with multiple blogs, run by different users.
Each user only being able to see and manage to their blog.
For each blog I create a role, a template, an user and a page.I'm creating everything through the api and only one thing doesn't work.
When I login as one of these users I can't see the page (in the pages tree in the admin dashboard) set up as their blog root.But if I go and edit role assigned to the user and just click save (no other changes)
then the page appears after a refresh and I can edit it and add child pages.Here's the code
Spoilerfunction create(string $name, string $blogName) { $role_ = wire()->roles->get("{$name}_blog_editor"); if (!$role_->id) { $role_ = wire()->roles->add("{$name}_blog_editor"); $permission_ = wire()->permissions->get("page-edit"); $role_->addPermission($permission_); } $user_ = wire()->users->get("{$name}"); if (!$user_->id) { $user_ = wire()->users->add("{$name}"); $user_->pass = "q"; $user_->addRole($role_); $user_->save(); } $homeTemplate = wire()->templates->get("home"); $blogPostTemplate = wire()->templates->get("blog_post"); if (!$blogPostTemplate->id) { $blogPostTemplate = wire()->templates->add("blog_post"); $blogPostTemplate->noChildren = 1; $blogPostTemplate->save(); } $template_ = wire()->templates->get("{$name}_blog"); if (!$template_->id) { $template_ = wire()->templates->add("{$name}_blog"); // give access to the role $template_->useRoles = true; // only the newly created role (and the admin) has access $template_->editRoles = [$role_->id]; // array of roles that can edit pages with this template $template_->createRoles = [$role_->id]; // ... can create pages ... $template_->addRoles = [$role_->id]; // ... can add child pages ... $template_->addRole($role_); $role_->save(); $template_->save(); // limit the child and parent templates $template_->childTemplates([$blogPostTemplate]); $template_->parentTemplates([$homeTemplate]); // add the title field $template_->fieldgroup->add("title"); $template_->fieldgroup->save(); $template_->save(); // set as allowed parent template for the "blog_post" template $blogPostTemplate->parentTemplates($blogPostTemplate->parentTemplates()->append($template_)); $blogPostTemplate->save(); } $page_ = wire()->pages->get("template={$name}_blog, name={$name}"); if (!$page_->id) { $page_ = wire()->pages->add($template_, "/", ["title" => "{$blogName}", "name" => "{$name}"]); $page_->save(); } }
What am I doing wrong?
-
-
Try falkon and qutebrowser.
- 1
-
Quote
any replies to the parent are still having indent applied to the right
Cause you're not closing your divs correctly.
You open 5 divs and only close them all when there are replies, if there are no replies you only close 4.
-
-
Disregard my comment, I didn't take some things into consideration.
Should have made it clearer what I meant though: "Considering the drawbacks I listed, i don't think the functions API should be the default".
- 1
-
Quote
The functions API is specifically built as a convenience for front-end website or application development. While it can be used anywhere, it is not intended for modules and back-end processes/hooks.
QuoteNot all API variables are available as functions. Only those that are likely to be needed on the front-end of a website or application are available as functions
-
Which regular templates do you mean?
A new template contains only the title field and doesn't return anything until you create a template file and tell it to return (echo) something.
- 1
-
You can get all fields of a page, that are editable by the current user, like this:
$p = wire("pages")->get(5994); foreach ($p->getFields() as $pField) { foreach($p->getInputfields($pField->name) as $inputfield) { if(!$p->editable($inputfield->name, false)) { continue; }; // need tracy debugger for bd bd("is editable: {$pField->name}"); } }
- 1
-
@MarkE Have you seen the access tab on templates and fields?
https://processwire.com/api/user-access/ and maybe https://processwire.com/blog/posts/building-custom-admin-pages-with-process-modules/
-
public function matches($selector) { // This method implements the WireMatchable interface return $this->comparison()->matches($this, $selector); }
@bernhard I think $this->comparison()->matches($this, $selector) is PageComparison->matches(Page $page, $s) which doesn't accept an array, it only checks for a string or int and a selector, else returns false.
- 1
-
1 hour ago, MarkE said:
I'm not sure what the API would be to create a new page directly.
$p = new Page(); $p->template = 'template_name'; $p->parent = $pages->get('/about/'); $p->name = 'mynewpage_url'; $p->title = 'My New Page'; $p->save();
Edit the page
$p = $pages->get('/about/mynewpage_url/'); $p->title = 'My New Page (updated)'; $p->save();
-
3 hours ago, kongondo said:
I decided to try Docker
Check out devilbox.
3 hours ago, kongondo said:I then tried to locate the path to PHP and couldn't find it! It turns out 'one can't find it in Docker?'
I just installed php on my system and use that one.
- 2
-
39 minutes ago, kongondo said:
Do you know if I can setup wireless access to the printer using Cups?
I don't have a wireless printer nor a scanner so can't help with that.
Maybe this will help with the wireless printing https://www.makeuseof.com/tag/setup-wireless-usb-printer-linux/
- 1
-
@kongondo Open the software center, search for and install cups. Then you should be able to open the cups admin in the browser at http://localhost:631/admin (you will need to login with your solus user) and there you can manage the printers.
- 1
-
I recommend you Solus with the plasma (kde) desktop, it's still in beta (the plasma version), but I had no issues with it. You can download it here., or check the other desktops available.
Here is a screenshot of the taskbar and start menu (start menu is a custom one, plasma comes with 3 by default)
With some distros you have to add extra repositories for codecs and drivers, which is not always straight forward, Solus provides them in their main repos.
- 1
-
On linux distros you use package managers to install software (packages).
If there is no package you need to build and install the software from source, which can be a pain in the ass, especially if it has many dependencies (you have to build and install those too).
9 hours ago, FrancisChung said:So you recommend a separate, entire partition for applications only?
No, just devilbox (not the entire partition just for devilbox though). You can do that for other apps to but it gets complicated.
9 hours ago, FrancisChung said:I'm guessing this wouldn't work if I switched distros for example right? Does it still work if you go from different versions of the same distro?
For devilbox it will work, as long as you have docker and docker-compose installed. For other apps it depends, some will work some will not.
-
Why did you install it in /opt?
I put it on a separate partition so when/if i reinstall i don't have to back up and restore them.
- 1
-
14 minutes ago, FrancisChung said:
It was mainly using sudo to launch the application. The documentation doesn't state that you had to use it
Do you mean docker compose up|down commands? It works without sudo for me.
-
-
Give https://github.com/cytopia/devilbox a try.
- 2
-
Send the id of the page you want to save in the ajax request, then get the page based on the id.
- 2
-
Your problem is not with PW since you're not even reaching PW, from what you said. Your problem is most likely with pointing the domain to the new server.
So take it slower, instead of moving PW just put a index.html (this eliminates most steps) file on the new server and try to access that. Once you reach that index.html start moving PW.
- 2
-
Your problem is unrelated to PW.
You can read here how to move a PW site, but the steps apply to most CMS's, just step 5 is specific to PW in that the file name and its location differ from cms to cms. That's why i said it's unrelated to PW, there is nothing special about moving a PW site compared to moving any other site.
23 minutes ago, henri said:My hosting provider isnt going to help me
Have you actually contacted them?
And as I said before no one can help you with the little info you provided. What kind of hosting do you have (shared, vps etc)? Do you have a control panel? Do you have phpmyadmin? Who handles your domain?
- 1
Set template access rules from api
in General Support
Posted
Figured it out... seems like I have to get the role again and turn of output formatting