Jump to content

Include from assets/


rooofl
 Share

Recommended Posts

Hello, beginner here.

First, Processwire is amazing. I try it from yesterday and already made so much progress!

A field allow me to unzip an archive in assets/. Now I would like to include in my template a stylesheet.css extracted from the archive.

I think I meet some permission issue because nothing is included. Can you confirm and help me?

$fontlist = $pages->get("/fonts/"); 
foreach($fontlist->children as $child){
  $stylesheet = $child->webfont_archive->url.'stylesheet.css';
  echo "<a href='".$stylesheet."'>".$stylesheet."</a>"; // This link is ok
  include($stylesheet); // Nothing here 
}
Link to comment
Share on other sites

Welcome to PW!

Try using "->path" instead of "->url" as you need the full path to the file on the server when using include.

That said, do you really want to "include" the stylesheet?

Do you simply want:

<link rel="stylesheet" href="'.$stylesheet.'" type="text/css">
 
Link to comment
Share on other sites

Glad you got it working.

Have you seen the API cheatsheet?

http://cheatsheet.processwire.com/

path vs url is explained there for use in both $page-> and also $file->

Your best way to really figure some of this stuff out is to echo the results to the page.

echo 'url: ' . $child->webfont_archive->url . '<br />path: ' . $child->webfont_archive->path;

That way you can see exactly what is being returned.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By AndZyk
      Hello,
      we have many projects as pages containing images inside regular image fields and repeater matrix elements. Now we would like to organize our assets.
      ProcessWire saves assets with id as folder name and makes separate folders for repeater matrix elements.
      Is there a way to collect all assets of one page and export them in a folder with the page name/title?
      I think I could achieve this by using the command line wget for this website or maybe by a hook. But maybe someone has done this before. 😉
      Regards, Andreas
    • By jonatan
      "Permission “page-sort” for template “ ... ” not allowed (requires “page-edit” permission)"

      – This lovely error message is thrown at me, if, as implied by it, I try to add (to my "editor" role) the permission "page-sort" for a specific template, without the permission "page-edit" enabled for the same template.
      Seems like it's been mentioned a few times before but never properly answered, by e.g. @Robin S ... :  
      "Allow the granting of page-sort permission independent of page-edit": https://github.com/processwire/processwire-requests/issues/29
       
       
       


      Why do I wanna do this?:

      I have a page tree structure  🌳  as so:

      ________________________

      Category [C1]
      – Page a [C1_p] – Page b [C1_p] Different category [C2]
      – Page c [C2_p] – Page d [C2_p] ________________________

      The page "Category" has the page-template "C1",
      the pages "Page a" and "Page b" both have the page-template "C1_p".
      The page "Different category" has the page-template "C2"
      the pages "Page c" and "Page d" both have the page-template "C2_p".
       
      The two pages called "Category" and "Different category" do not have any content, they only serve as containers for pages belonging to that category.
       
      I want my "editor" role not to be able to do anything at all with these pages "Category" and "Different category"; i.e. I do not want my editor to be able to edit, move, unpublish, hide, lock, delete (or do anything else to) these category pages. 
      – So, I want my "editor" role to have the "page-edit" permission for pages with the templates "C1_p" and "C2_p", but not for the pages with the category templates "C1" and "C2",
      Also, I want my "editor" role to be able to move the pages with the templates "C1_p" and "C2_p" within their parent-pages. 


      Problem:

      But if I just simply add the "page-edit" and the "page-move" permissions for the "C1_p" and "C2_p" templates, then, using the "editor" role, I am not able to move these "C1_p" (and "C2_p") -template-based pages. I can actually click "MOVE" next to them and then move them, but... then I will be met by the error message "You do not have permission to sort pages using this parent - /Category/".  
      – So, I try to add the "page-sort" (description: "permission to sort child pages") permission to the "C1" and "C2" templates... but then trying to do so I am met by the initially mentioned error message   ! Permission “page-sort” for template “C1” not allowed (requires “page-edit” permission)  . 
      And, as mentioned, I do not want my editor role users to be able to edit these category ("C1" and "C2") pages...
      – what to do about this? 😅 
       
      All the best,
      Jonatan 
    • By horst
      Hi, on a site I want to disable access to original images and only allow to access thumbnails and watermarked image variations.
      EDIT:
      A good solution for protecting original images can be found a bit down in this thread:
       
      Old content of this initial post:
       
    • By AndZyk
      Hello,
      I have a user role employee with the permission page-edit-created. This user role has access to add new pages to the template posts with the template post.
      The template posts should have children with the template post. The template post should have the parent with the template posts. Now every time I try to add a new page with the template post, an exception throws:
      You don't have access to the template required to add pages here
      Is this a bug in this permission or have I not configured the permissions correct?
      Is there a hook to allow to add pages to the template posts for the role employee?
      I would appreciate some help. 😀
      Regards, Andreas
    • By Slideth
      Hi! I am new to processwire and really like working with it so far.
      For a relaunch project, some editors of our website need the permission to add redirect URLs while migrating the content. I already created a role "site-manager" so only a few team members have access to certain features.
      There is also the option to add redirect URLs in the page settings, but it seems to be restricted only to superusers. Does anyone know of a way to grant permission for this option to another user role?
      Since this is the first PW-Project I did not dive in too deep with the permissions yet. I also tried to add a "page-edit-redirect"-permission, but I am somehow stuck on what to do with it.
      Thanks
×
×
  • Create New...