Jump to content

How to use own html in PW?


lord_dupalski
 Share

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

Link to comment
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
Link to comment
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?>'.

Link to comment
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
Link to comment
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
Link to comment
Share on other sites

Hi Dupalski

Take a look at this:

http://wiki.processwire.com/index.php/Basic_Website_Tutorial

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:

<?php

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
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...