Jump to content

How to use own html in PW?

Recommended Posts

I have created my static html front page for my website. a pretty basic one.

How do I use it on PW?

Do I delete files from site/templates directory?

and replace it with the html/css files of my basic website?

Tried to delete fields and pages in admin which comes with the default installation of PW.

But I cant delete them, it says template/field cannot be deleted.

Anyway, I really need to know the steps to use my own static html?

Thanks for the help

Share this post

Link to post
Share on other sites

Finally was able to delete templates , pages and the fields and made it barebones.

Created index.php in site/templates with basic HTML5 Coding.

Also did the planets tutorials and did not delete the fields and pages.

But nothing shows up in my front end?

Share this post

Link to post
Share on other sites

How to use own html in PW?

Use your own html in header.inc and footer.inc or any .inc you want for your own html

that is going to show up on all your website pages.

For your individual html that shows up only in certain pages,

use it directly in any template file. In fact you can use php echo to output any html

at any place in your website. Does that make sense ?

I have to go to work now, so I have no time left to find posts in the forum where

this is shown with examples. Will see how this thread is going when I am at work.

Otherwise will post back. Stick around here.

  • Like 1

Share this post

Link to post
Share on other sites

is there any other approach other than seperating it wint .inc's?

I do get it, but it is much simplier and easier for me to understand if I put everything in index.php

very similar how I do it in modx revo, I have an index.html copy the code in modx where everything in front page is in there and create template variables and call those template variables on area's or div's  I want to put them.

i just want a index.php file where eveything I need to show in my front page is in there. (I'll put code in index.php with the code in my static index.html)

then from index.php there I will call the fields '<?=$page->field_name?>'.

Share this post

Link to post
Share on other sites

It might seem simpler and easier but is is neither efficient nor very wise :-). Of course, you can do it this way but your will repeating yourself over and over and over and over....in each template file that uses the same markup :-) But you can certainly do it that way - you do not have to use includes or split your template files. ProcessWire itself doesn't know or really care  :P  :lol: .....Yes, the fields would be your MODx TVs....As for index.php, no need to call your template file that (at least to avoid confusion with PW's index.php - although I am not sure it would cause any problems). So, call it home.php, or whatever. Again, PW doesn't mind much since you will not see home.php in the URL anyway!

Edited by kongondo
  • Like 1

Share this post

Link to post
Share on other sites

@dupalski: for the record, you might want to check out the "beginner site profile" Ryan has posted here.

Just to be very clear: include files (.inc, .php, whatever) are definitely not a requirement.. and on very simple sites they just make things more complicated. On larger and more complex sites that situation changes drastically.

  • Like 2

Share this post

Link to post
Share on other sites

then from index.php there I will call the fields '<?=$page->field_name?>'.

Exactly, but instead in index.php do that in home.php and basic-page.php


Share this post

Link to post
Share on other sites

Hi Dupalski

Take a look at this:


It is a little out of date, but work through it and you will learn all you need.

Ignore index,php - Everything you need to do is in /site/templates - just think of that as the root of your site.

For instance, the home.php file is the template for the home page.

Do this as an experiment.

Make sure in your admin you have the "home" page and it is using the "home" template. It is there by default.

Open your home.php file and delete EVERYTHING.

Now type:

"This is the home file"

Go to the front end of you website = mywebsite.com

It will display This is the home file - with no mark up obviously!

Now, edit the file again and add below the line:


echo $page->title;


Reload the page and it will now display

This is the home file Home

It has added the title of the home page.

Now, go and add proper html mark up - <html>, <head> and the rest. In the body put:

<h1><?php echo $page->title; ?></h1>

Reload and you will have a proper web page with the title as H1.

And that is how ProcessWire works!

As you add more fields to the template in the admin, so add them to your template file. For instance:

<?php echo $page->body; ?>

As for includes - there are various tactics for including other info. The most obvious one is splitting up the head, body and foot of the site as these tend to be common to all pages. But there are loads of different ways of doing this - ProcessWire has no set way, it is up to you how to do it. The only thing that is mandatory is that it MUST be in the templates folder and normally home.php would be your root template. To be honest, there is no reason to change that.

  • Like 4

Share this post

Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By hellomoto
      I can't tell what's wrong; my local development version appears just fine, but I copy over the site files and db online and the homepage content is not being contained. This is what it should look like (same site in the same browser, running on my localhost): http://imgur.com/UFZFzrd
      What could be the problem here? Sorry to bring up something so irrelevant to PW here, I just know that you all are a valiant and helpful group, and no one on StackExchange seems to even know what I'm talking about.
      Thanks a lot.
    • By picarica
      so i just downloaded this template  and i uploaded it to my server made some .php changes so it would work and stuff but all the css-transitions or css-animations don't work. they just stop
      if you checked out the template all those buttons are smooth and really nice, bit when you check out my site all those animations are gone, why is that? is there some option i have to toggle? or is it normal? how do i fix it ?
    • By alanxptm
      Hi, I have already tried in different ways and many times to migrate but I always have issues at the end.
      Here's what I have done so far:
      case 1:
      1. Install PW on live server (all normal)
      2. Import local DB into live DB
      3. Front page site seems to work but I cannot login into admin page
      case 2 (I'm currently on this stage):
      1. Copied all files from local to live server
      2. Import local DB into live empty DB
      3. Front page works, but any other page and admin page are 404
      In both cases:
      - I have changed config.php info accordingly to live server (DB name, DB user and pwd, userauthsalt code)
      - Uncommented RewriteBase / and RewriteBase /pw/ lines on .htaccess
      - applied owner and group permissions to www-data for PW location
      - applied permissions to folders and files accordingly
      - applied a2enmod rewrite to apache2 on live server and restarted service
      I have read some posts (Ryan's too) about migration and it seems to me that I'm doing it fine, don't know what it fails-
      I'm on VMWare machine, Ubuntu Server 18.04, php 7.2, phpMyAdmin 5.0.1
      Hope you can help me, thanks in advance
    • By rushy
      Hi. I've been using Processwire for a few years now and installed it on a few different shared hosting servers without issues, but I'm now running into an issue on a Fasthosts shared server that I've not seen before. The installation goes ok and I have a working default site profile but I am unable to complete any uploads of images. It just hangs at the progress spinner during the upload. I thought it might be a priviledge issue so have temporarily set the dir / file privs. as 777 / 666 just to test that but it made no difference. I have no errors in the wire log. In server error log I have:
      set_time_limit() has been disabled for security reasons in ....htdocs/wire/core/ImageSizerEngine.php on line 1035 and i note in the assets/file dir. where the image is being stored the date on the file being created has a year of 1970 and 0 length. If I leave the page this file disappears and nothing has been stored. 
      Does anyone know how I can enable set_time_limit if this is likely to be the problem? 
      Many thanks! Paul
  • Create New...