Jump to content

HOW to create featured Post


drilonb
 Share

Recommended Posts

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

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

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

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

Yes, looks nice.

Small typo in the copyright line, can you spot it ?  :D

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

@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

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