Mijo Posted October 23, 2016 Posted October 23, 2016 Hello everyone, I have a question, how to call a field from one template to other template? For example; I have a phone field on the homepage, I want to display this information on template about us? I call that field on homepage like this: <?php echo $page->phone; ?> I'll try to do that on template about-us, display same information from that field (phone), but nothing happened? Is there any easy way to do that, to show the same field in different templates? I hope it is clear what I want to do Thanks in advance
fbg13 Posted October 23, 2016 Posted October 23, 2016 // "/" is the home page $home = $pages->get("/"); echo $home->phone; 1
Mijo Posted October 24, 2016 Author Posted October 24, 2016 9 hours ago, fbg13 said: // "/" is the home page $home = $pages->get("/"); echo $home->phone; Thank you for your answer. This option is ok, but it outputs number 1 on about-us template, like this 1+123456789 it should be +123456789, I don't know what is a problem. Thank you in advance.
szabesz Posted October 24, 2016 Posted October 24, 2016 44 minutes ago, Mijo said: This option is ok, but it outputs number 1 on about-us template, like this 1+123456789 Are you sure about this? Simply outputting a field should not prepend anything to the field's value. Can you post the exact code snippet you use?
3fingers Posted October 24, 2016 Posted October 24, 2016 $home = $pages->get("/"); // It returns the ID of the page, 1 because is the homepage $home = $pages->get("/")->url; // It returns the homepage path Edit: Probably not related with the behaviour you are facing. Are you using the "phone" field? 1
fbg13 Posted October 24, 2016 Posted October 24, 2016 1 hour ago, Mijo said: Thank you for your answer. This option is ok, but it outputs number 1 on about-us template, like this 1+123456789 it should be +123456789, I don't know what is a problem. Make sure you're not echoing $home = $pages->get("/"); too, can't think of another reason. 1
Mijo Posted October 25, 2016 Author Posted October 25, 2016 It's working now, all I have to do is restart server Thanks everyone 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now