Jump to content

How to access to fields value


Sten
 Share

Recommended Posts

Hi,

I have a lot of difficulties with getting a field value.
First I created a template, inside I created several fields
two fields are a dropdown select box So I have a value and a label for each line.

Then I want to get the field value in _init.php or in the template to display it. How can I get the value of a field for the page ? I need to understand the flow through which data goes.
Could someone help me ?

Thank you

 

 

 

Link to comment
Share on other sites

Why don't you use a pagefield?

It's as simple as using $page->fieldname (inside the template).

In _init.php, you would use $pages->get(123)->fieldname, where 123 is the id of the page your field lives in.

If you have multiple instead of single values, you would have to loop through them, but that's easy as well.

Link to comment
Share on other sites

Thank you Dragan,

I do that then i want to transform data to display in my template :

$view->set('categorie',${"cats_".$lang}[$page->cat]);

Here I have an array for each language. $page->cat displays an integer, I tested it. If I replace $page->cat with an integer to test, it works but with the expression as a key, it does not work.

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