Jump to content
Sign in to follow this  
DJkikisa

Primitīvs foruma jaunumu skripts

Recommended Posts

<?php
/* Norādam ceļu uz galveno foruma mapi*/
require $_SERVER['DOCUMENT_ROOT'].'/init.php';
$news_id = 2; /* Noregulējam no kura foruma sadaļas izvilkt jaunumus */
$limit = 5; /* Noregulējam cik jaunumus izvada */
$news	= \IPS\Db::i()->select( '*', 'forums_topics',[ 'forum_id=?', $news_id , 'topic_hiddenposts' ,0],'tid desc', $limit  );
$news = $news->join( 'forums_posts', 'forums_posts.pid=forums_topics.topic_firstpost', 'LEFT' );
foreach( $news as $row )
{
$news_link_fix = str_replace("<___base_url___>", rtrim(\IPS\Settings::i()->base_url,"/"), $row['post']);
?>

<h1><a href="<?php echo\IPS\Settings::i()->base_url.'topic/'.$row['tid'].'-'.$row['title_seo'];?>"><?php echo $row['title'];?></a></h1>
<h4>Tēmu uzsāka : <img src="<?php echo \IPS\Member::load( $row['author_id'] )->get_photo();?>" width="25px"> 
<a href="<?php echo\IPS\Settings::i()->base_url.'profile/'.$row['author_id'].'-'.$row['author_name'];?>"><?php echo $row['author_name'] ;?></a>
- šādā laikā: <?php echo date("Y-m-d H:i:s",$row['post_date']);?>
- tēma ir saņemusi <?php echo $row['posts'] ;?> ierakstus un <?php echo $row['views'] ;?> skatījumus.
</h4>
<?php echo $news_link_fix; ?>

<h6>Pēdējo komentāru veica: <img src="<?php echo \IPS\Member::load( $row['last_poster_id'] )->get_photo();?>" width="25px"> 
<a href="<?php echo\IPS\Settings::i()->base_url.'profile/'.$row['last_poster_id'].'-'.$row['last_poster_name'];?>"><?php echo $row['last_poster_name'] ;?></a>
- šādā laikā: <?php echo date("Y-m-d H:i:s",$row['last_real_post']);?>
</h6>
<?php } ?>

Demo: https://wam.lv/skripti/ipbnews.php

  • Upvote 1

Share this post


Link to post
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
Sign in to follow this  

×