Menu icon Foundation
Change default.html to default.php

I need to use php but I can't change the file extension of default.html, from /layouts/default.html to /layouts/default.php. 

Related: 

I can't use any partials that have .php as a file extension either. I see some people are using PHP in F6 Zurb Template, but I am seriously stuck. 

Does anyone have a repo I can look at to see how you did it? Any ideas?

PHPsitesPartialsdefault.htmldefault.php

I need to use php but I can't change the file extension of default.html, from /layouts/default.html to /layouts/default.php. 

Related: 

I can't use any partials that have .php as a file extension either. I see some people are using PHP in F6 Zurb Template, but I am seriously stuck. 

Does anyone have a repo I can look at to see how you did it? Any ideas?

Brian Tan over 3 years ago

You can tweak gulpfile.js to look for php files in src/pages. File extension in src/layouts remains as html.

// Copy page templates into finished HTML files
gulp.task('pages', function() {
  return gulp.src('src/pages/**/*.{php,html,hbs,handlebars}')
.....

Joshua Smith over 3 years ago

Thanks for responding Brian. I have a couple of posts here relating to the use of php with F6. I was hoping you'd respond. 

Alas, I already saw your response to another user's questions and I had already made those changes in my Gulpfile.js.

I can't do a few things: use a .php file extension in my partials and change the default.html to default.php. The former would allow me to use leverage syntax highlighting and the power of PHPStorm and the latter would allow me to use php on the home page. 

 

I'm still experimenting. 

Brian Tan over 3 years ago

Can you do a symbolic link default.html -> default.php ?

Joshua Smith over 3 years ago

Wouldn't that link be destroyed every time Gulp builds the dist directory?

Brian Tan over 3 years ago

The links would be in src sub-directories. dist directory would only contain flattened php files from src/pages. I don't think gulp touches files or links in src subdirectories.

Joshua Smith over 3 years ago

Nope. The symlink didn't work. Isn't there a way to flatten php files? 

Brian Tan over 3 years ago

How about this.

 

src/pages/test.php

---
layout: testlayout
---

....

src/layouts/testlayout.php

Symlink testlayout.php to testlayout.html (for panini)

I can then vi testlayout.php with php syntax highlight. Similar setup for partials.

when built, src/pages/test.php would be flattened to dist/test.php

Should work with default layout too.

Joshua Smith over 3 years ago

Sweet. That worked for me too!

I just need to find a way to make default.html -> default.php

I'm trying to use $_SESSION variables on each page and session_start(); hast to come before any HTML

 

I wish there was a way to have Gulp do it. 

 

Joshua Smith over 3 years ago

Brian, I went back to your idea about symlinking the default.html file. 

 

I cut the guts out of the default.html and pasted it into default.php. I then deleted default.html and went back to the terminal to symlink default.php to default.html, as you said for Panini. It worked!

I get my php syntax highlighting and get to use php on the default template. 

 

Darcy Madi over 3 years ago

Joshua and Brian - thank you SO much for having figured this PHP thing out...that symlink piece was solid gold...totally tricked Panini into (finally!!) accepting my PHP version of the default file.