Jump to content

Pass data to a Processwire page


cssabc123
 Share

Recommended Posts

Unlike the tutorial example HelloWorlds (http://processwire.com/docs/tutorials/hello-worlds/) about the planets Earth and Jupiter.   Is there a way to pass data to a Processwire page coming from 1) MySQL database or 2) Another Processwire page?  That way I can have a database table of planets and  just create one or two pages. One page if I had a dropdown of planets then output planet data on same page when a planet is chosen from the dropdown. Maybe 2 pages if I implement a holder/page pattern where the holderpage  will have links of planets, and once a planet link  is clicked, fetch planet data from the  database for info then output fetch data to a detail page?

Link to comment
Share on other sites

Welcome to ProcessWire cssabc123,

 

You interact with data in ProcessWire via the fields from a page. A page in ProcessWire has custom fields (where the data is).

Every Page in ProcessWire is build from a template, that template tells the Page which fields the page has. In fact a template is a 'template' for a Page, you could call it a Page factory. 

 

Every template can have a template file. (the files in /site/templates/). When a Page has a template with a template file the page can be shown in the browser. When a Page is build from a template that has no template file, the Page can only be used as data container.

 

But how do I get the data from an other Page you might think. That is where the $pages variable comes in. Go ahead and check out the docs.

  • Like 1
Link to comment
Share on other sites

Hey Martijn and cssabc123,

First post here. I've been with ProcessWire for exactly two days now. I'm coming from an ExpressionEngine, concrete5 and MVC (CakePHP mostly) background.

Just checking if I understand you correctly, Martijn. To enter all the planets, one might create pages in the Tree with a template "planet", which would constitue one's dataset (or container) of planet data. Then, on any given page, you could for instance create a listing or a dropdown via $pages->find("template='planet', sort=title").

(That would remind me most of ExpressionEngine, where the data you enter into a channel can be output anywhere you like with {exp:channel:entries channel="planets"})

So in this case, the planet pages would not really constitute pages as such (although they might), but a set of data. Rows in a database, if you will.

Just wrapping my head around stuff.  :)
 

Bye... Nico

Link to comment
Share on other sites

Just checking if I understand you correctly, Martijn. To enter all the planets, one might create pages in the Tree with a template "planet", which would constitue one's dataset (or container) of planet data. Then, on any given page, you could for instance create a listing or a dropdown via $pages->find("template='planet', sort=title")

You got it...

You could think that it's a row in the database but that's not the case. (Dive in MySQL to find out)

Every field is stored separately with the ID of the page. So ProcessWire makes joins (indexed) to give you all the data back what you're asking ProcessWire. So Loading a page and calling the title will only load the title, leaving the other fields alone...

.....

silly me... Welcome Nanook !

Edited by Martijn Geerts
say hi to nanook..
  • Like 5
Link to comment
Share on other sites

Is there a way to pass data to a Processwire page coming from 1) MySQL database or 2) Another Processwire page?

Not sure your exact needs, but this module might also be of use: http://modules.processwire.com/modules/fieldtype-select-ext-option/ - it allows you to generate a dropdown/radio/checkboxes etc from an external database table.

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