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

×
×
  • Create New...