drilonb Posted April 14, 2011 Posted April 14, 2011 Hello i am a new with this CMS i like to know if its possible to call fields like: I create one template Slides.php and add fields Image and text , i like to call fields of this template to other template name like in home.php slider work in slider page but not in other pages , example of your template <?php // Grab a random image from the homepage and display it. // Note that $homepage was loaded above where we generated the top navigation. if(count($homepage->images)) { $image = $homepage->images->getRandom(); $thumb = $image->size(232, 176); echo "<a href='{$image->url}'><img id='photo' src='{$thumb->url}' alt='{$thumb->description}' width='{$thumb->width}' height='{$thumb->height}' /></a>"; } ?> how to creat like this to call other pages not from homepage . i try this but works only in sliderat template <?php if(count($page->sliderat->slider1)) { $image = $page->sliderat->slider1->getRandom(); $thumb = $image->size(400, 200); echo "<img id='photo' src='{$thumb->url}' alt='{$thumb->description}' width='{$thumb->width}' height='{$thumb->height}' /></a>"; } ?> Ame sorry for my language.
ryan Posted April 14, 2011 Posted April 14, 2011 I'm confused by the field/page names -- is the name of the field "sliderat" or "slider1"? But lets assume there is a field named "images" on the page "/mypage/" and you wanted to pull a random image, like in your example: You'd do it like this: <?php $mypage = $pages->get("/mypage/"); if(count($mypage->images)) { $image = $mypage->images->getRandom(); $thumb = $image->size(400, 200); // if you need a thumbnail // then output the thumbnail and/or image like in previous examples } Also, you had mentioned templates in a context that I'm not sure I understood. Templates define a type. You don't pull data from a template, but from pages that use that template. So think of templates like the database schema for a table, and pages like the rows of data in that table.
drilonb Posted April 15, 2011 Author Posted April 15, 2011 Thanks a lot i understand now functions and work perfect now the slider is working great i will start using now this for my new sites, you can check the slider http://sherbimeonline.com/webi/ Thanks RYAN...
drilonb Posted April 15, 2011 Author Posted April 15, 2011 Yes i am just finishing my work , i am trying to make one gallery maybe i will finish it. and images are opening like charm with popup jquery , i am confuse how to make a page like this > http://processwire.com/skyscrapers/cities/atlanta/ i really love it. BR,
ryan Posted April 15, 2011 Posted April 15, 2011 I just emailed you a link to download the skyscrapers site profile/installation if you want to take a look at it.
drilonb Posted April 15, 2011 Author Posted April 15, 2011 Thanks RYAN i am just waiting for mail and to try it
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