drilonb Posted April 18, 2011 Share Posted April 18, 2011 Hello i like to know how to make something like featured post or most view post field for this i use popularpost and template name is news, i like to know how to use it in template, i have try to use like this form and to set and first image on it, its posible ? <ul> <?php $features = $pages->find("template=press_release, featured=1, limit=3, sort=-date"); foreach($features as $feature) { echo "<li>" . "<h3><a href='{$feature->url}'>{$feature->title}</a></h3>" . "<span class='date'>{$feature->date}</span>" . "<p>{$feature->summary}</p>" . "</li>"; } ?></ul> Link to comment Share on other sites More sharing options...
ryan Posted April 18, 2011 Share Posted April 18, 2011 If I understand correctly, I think you are wanting to do something like this? <?php $p = $pages->get("template=news, popularpost=1"); echo "<p>"; echo "<a href='{$p->url}'>{$p->title}</a>"; if(count($p->images)) { $img = $p->images->first(); echo "<img src='{$img->url}' alt='{$img->description}' />"; } echo "</p>"; Link to comment Share on other sites More sharing options...
drilonb Posted April 18, 2011 Author Share Posted April 18, 2011 Great workkkkkk Thankss Link to comment Share on other sites More sharing options...
drilonb Posted April 18, 2011 Author Share Posted April 18, 2011 And one problem when i add thumb or body description, <?php $p = $pages->get("template=news, terejat=1, limit=3, sort=-date"); echo "<p>"; echo "<a href='{$p->url}'>{$p->title}</a>"; if(count($p->fotka)) { $img = $p->fotka->first(); $thumb = $image->size(200, 200); echo "<a href='{$p->url}'><img src='{$thumb->url}' alt='{$thumb->description}' /> </a>"; } echo "</p>"; ?> show error on page line where is $thumb = $image->size(200, 200); Link to comment Share on other sites More sharing options...
ryan Posted April 18, 2011 Share Posted April 18, 2011 There is no variable called $image in there from what I see. Are you sure you don't mean: $thumb = $img->size(200, 200); ($img rather than $image)? Link to comment Share on other sites More sharing options...
drilonb Posted April 18, 2011 Author Share Posted April 18, 2011 Great i am so stupid with code i type wrong. <?php $p = $pages->get("template=news, terejat=1, limit=3, sort=-date"); echo "<p>"; echo "<a href='{$p->url}'>{$p->title}</a>"; if(count($p->fotka)) { $img = $p->fotka->first(); $thumb = $img->size(200, 200); echo "<a href='{$p->url}'><img src='{$thumb->url}' alt='{$thumb->description}' /> </a>"; } echo "</p>"; ?> the problem is showing just one post not others in template news is this for post per template " limit=3, " Link to comment Share on other sites More sharing options...
ryan Posted April 19, 2011 Share Posted April 19, 2011 The get() function returns just one page, but the find() function will return multiple pages (PageArray). As a result, there is no need to specify a "limit=3" with the $pages->get(), because only 1 page is already assumed. See this for more: http://processwire.com/api/variables/pages/ Link to comment Share on other sites More sharing options...
drilonb Posted April 19, 2011 Author Share Posted April 19, 2011 I am in the end of work with this CMS i am so happy i really i will use this CMS for my works. http://www.sherbimeonline.com/kta/ Thanks for all. Thanks RYAN Link to comment Share on other sites More sharing options...
ryan Posted April 19, 2011 Share Posted April 19, 2011 Looking good! Link to comment Share on other sites More sharing options...
jbroussia Posted April 20, 2011 Share Posted April 20, 2011 Yes, looks nice. Small typo in the copyright line, can you spot it ? PS: also, on the "Harta" page (contact ?) your emails are clearly visible even though there is a text message saying "This e-mail address is being protected from spambots. You need JavaScript enabled to view it." (I have javascript enabled by the way, so I think it shouldn't be here). So spambots have no problem finding your emails. Link to comment Share on other sites More sharing options...
drilonb Posted April 22, 2011 Author Share Posted April 22, 2011 @jbroussia yes i know first i need to finish all the site and in the end i will look to fix any bug in site like spam and others but first i am trying to lesson process wire function and start working with it. thanks for replay. Link to comment Share on other sites More sharing options...
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