Jump to content

relation of template and template files


adrianmak
 Share

Recommended Posts

I'm not sure should I ask in this board or General Support board.

I'm new on PW. I am following this tutorial

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

Templates in the administration are often associated with a specific Template File, but do not need to be, which can cause a little confusion. So, I will always say Template File when I am talking about the actual files and just Template for the templates in the admin.

As said, it is not necessary to associate a template in the admin to a template file.

What is it purpose without associate a template file?

Link to comment
Share on other sites

Templates without template files are often used to store data. Probably the simplest example is a typical category structure:

.
|-- home (template=home)
    |-- blog (template=blog)
    |   |-- blog-post-1 (template=blog-post)
    |   |-- blog-post-2
    |   |-- blog-post-3
    |   `-- blog-post-4
    `-- categories (template=categories)
        |-- category-1 (template=category)
        |-- category-2
        |-- category-3
        `-- category-4

Those category pages are connected via Page fields to other pages (such as the blog posts in this example), but they're not intended to be visited with their own URLs -- or rendered, so to speak. That's why you don't want them to have template files either.
 
Does this make sense to you?

  • Like 4
Link to comment
Share on other sites

Templates without template files are often used to store data. Probably the simplest example is a typical category structure:

.
|-- home (template=home)
    |-- blog (template=blog)
    |   |-- blog-post-1 (template=blog-post)
    |   |-- blog-post-2
    |   |-- blog-post-3
    |   `-- blog-post-4
    `-- categories (template=categories)
        |-- category-1 (template=category)
        |-- category-2
        |-- category-3
        `-- category-4

Those category pages are connected via Page fields to other pages (such as the blog posts in this example), but they're not intended to be visited with their own URLs -- or rendered, so to speak. That's why you don't want them to have template files either.

Does this make sense to you?

That is, if I want to list all assoicated pages with each category, a template file for category is necessary.

Link to comment
Share on other sites

I keep following the tutorial.

In  "Testing the layout with the Home page "

I load the site with new modified home.php

no body conten shown.

post-2272-0-69428000-1399269535_thumb.pn

I tried to comment the two include in home.php file. A blank page returned.

PW could not just

echo $page->body;

to display body field  content ?

ps I'm using PW 2.4

-------------------------------------

SOLVED

Link to comment
Share on other sites

That is, if I want to list all assoicated pages with each category, a template file for category is necessary.

That's right. It would be the most straightforward way to achieve that.

Link to comment
Share on other sites

To put it another way:

A template is the structure for a particular data set..

A page is one row of data

If you want to display any of that data you need to call it using the ALI

A template file associated with the template allows you to call from that page without having to specify the page - it returns that particular page

  • Like 1
Link to comment
Share on other sites

Sorry, Kongondo, typing on my tablet from the allotment. You are lucky that I didn't post it complete with the barrow load of horse shit that I had just picked up.

  • Like 1
Link to comment
Share on other sites

thanks all guys of yours for an explanation. ;)

While continue with the tutorial, The Name field is a system field which bound to any page and it reflect on an url path

However it could only allowed for ASCII chars. It is not an issue for western. But for asia region,  the title could be non-English chars. Then user will come across to think about of another English tex for the Name field. It could be inconvenience for those people.

post-2272-0-97320600-1399332235_thumb.pn

In drupal, path url allowed non-English string

Link to comment
Share on other sites

@adrianmak: there have been some discussions about non-ASCII (or international) addresses before:

https://processwire.com/talk/topic/3000-non-alphabetic-page-name/

https://processwire.com/talk/topic/5270-hebrew-in-url-sergments/

The gist of this is that ProcessWire addresses are URIs, but in order to allow other characters they would need to be IRIs -- the internationalised version.

I wouldn't be too surprised if this made it's way into core at some point, it just hasn't been seen as that big a factor so far. Most users are OK with current transliteration method, especially considering that Google might still prefer ASCII over international characters (some sources suggest so, but I'm really not an expert in this field).

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.
×
×
  • Create New...