Jump to content

Confused not having a record


ziusurda
 Share

Recommended Posts

I made ​​some test page for a new project and given a look to the database, but they are a bit confused.

Where are the records?

I am a DBA and have fields without tables, it seems strange, even if the good performance of processwire depend from this.

I created a page with a table. Simple, very simple with processwire.

Now I need a from to insert / update data on another page, and a button or a check box to delete the row.

I consulted the APIs, but other than delete Field and PaGE have not found anything.

I have to delete fields one by one?

(or am I doing something wrong?)

A book about processwire with examples would be welcome.

Link to comment
Share on other sites

Hi Ziusurda,

You need to setup your templates and fields in the admin section of your website and then use the API to output your content in your templates.

Take a very simple example:

You create a template called "basic.php"

<!-- Basic template-->

<h1><?php echo $page->title; ?></h1>
<h6>Created by: <?php echo $user->name; ?></h6>

<div class="body_copy">
<?php echo $page->body; ?>
</div>

Then in the admin, go to Setup->Templates and click Add, basic.php will show up, you can then assign fields to this template (you can add new fields at Setup->Fields)

Then create a page on the page tree and give it the template "basic". Now fill in the title and the body.

If you go to your website and view the page you created you ought to see the content you have outputted.

This is of course a very basic example. The API is very powerful and will enable you to output almost any content in almost any way you like.

  • Like 1
Link to comment
Share on other sites

To give you more of an example, you create fields for everything in Processwire so you may create a template "event"

For your events, you want to create

A date

A venue

A category

Multiple images

Files

To do this, you would first create the fields, selecting the type of field needed (there is much more information available in the docs) then you go to your chosen template and assign the fields to that particular template.

Say that you have a date field called event_date.

You could output that in your template using

$page->event_date

You will use the $page variable whenever you are accessing data from the page you are currently on.

If you need to get a field from another page, you would use the $pages variable.

  • Like 1
Link to comment
Share on other sites

Welcome to the forums ziusurda!

You don't really need to look on the database to work with PW, everything you need is in the administration area. There's where you create your templates fields and pages. To output the content on your website you also need the templates files.

But since you are curious about the database: All the pages are on the table "pages" and only keep info like "id" "name" "template" (foreign key with id of template), etc. The page table doesn't hold any fields, because each field has a table of his own, and each row holds the value and points to a page.

edit: wow, you were quick onjegolders!

  • Like 1
Link to comment
Share on other sites

Welcome to the forums ziusurda!

You don't really need to look on the database to work with PW, everything you need is in the administration area. There's where you create your templates fields and pages. To output the content on your website you also need the templates files.

But since you are curious about the database: All the pages are on the table "pages" and only keep info like "id" "name" "template (foreign key with id of template)" etc. The page table doesn't hold any fields, because each field has a table of his own, and each row holds the value and points to a page.

edit: wow, you were quick onjegolders!

I'm on a mission! Trying to give back after all the millions of questions I've asked myself....

  • Like 6
Link to comment
Share on other sites

HI ziusurda

When you are looking through the Database itself, one thing worth noting is because each field you create in the Admin (Setup > Fields) has its own table, the data stored is very clean.

This makes it very easy to deal with in your Template File in the /site/templates/ directory of your installation. Any stylisation is up to you.

It is also worth noting that the DB structure allows every field to be reusable. They are not permanently associated to one particular template, but can be associated with many.

So, you may create an article_meta_keywords field that you want to use in lots of different templates since it is a very common element. When you create a template in the backend, you can add whatever fields you like from the drop down list, so this is not only possible, but very useful!

I have just written a full tutorial that explains some of these issues. It sounds like you may not need to do the entire thing, but reading it through might put some of this into context.

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

I am still cleaning it up, but a lot of the info is there!

Please let me know if there is anything in it you find confusing - I will sort it out.

Joss

  • Like 2
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...