Page 1 of 1

{NEW:10} problem - not right solution...

Posted: Mon 27. Dec 2004, 17:51
by maarek
Hello.

In "site structure" I have 'New". I can put articles there. And on homepage I want f.e. to show shortcuts to last 10 of them. The shortcut (the link) should be tect + little image. How can I do this? Becouse "{NEW:10}" shows articles from everywhere.
And how can I put another page "news archive" with all links from this part?

Regards, Marek.

Posted: Mon 27. Dec 2004, 17:56
by Pappnase
hello

use the related tag!
give them an keyword e.g. *NEW*

Code: Select all

{RELATED:list_count_:keyword}
http://www.phpwcms-docu.de/link_tags.phtml

Posted: Mon 27. Dec 2004, 18:02
by maarek
Thank you. I know that it works, but I need to be able to show this without keywords adding. What when I want to move articles to "news archiwe"? I saw somewhere tags like "{NEWSA:100:6}" but don't know how it worked...

M.

Posted: Mon 27. Dec 2004, 18:08
by Pappnase
hello

thats not possible at the moment execpt zu wrote an new replacement tag!

Posted: Mon 27. Dec 2004, 18:10
by maarek
How can I wrote such tags?

Posted: Mon 27. Dec 2004, 18:11
by Pappnase
hello

i think in the hacks forum part is an tutorial! how to write own replacement tags!

{NEWSA} Tag

Posted: Sat 1. Jan 2005, 14:56
by creep
This code save as file phpwcms_template/inc_script/frontend_render/newsa.php

Code: Select all

<?php 

/*************************************************************************************
  usage:
  {NEWSA:10} - show last 10 active articles(exluding current article) from all section where categories is active, public, not hidden and not trashed	
  {NEWSA:10:CURRENT} - show last 10 articles from current section(exluding current article)
  {NEWSA:10:_ID_NUMBER_} - show last 10 articles from _ID_NUMBER_ section

*************************************************************************************/

// all new article list sorted by date
if( ! ( strpos($content["all"],'{NEWSA:')===false ) ) {
	$content["all"] = preg_replace('/\{NEWSA:(\d+)\}/e','get_newsa_articles($template_default["news"],$1,$db);',$content["all"]);
	$content["all"] = preg_replace('/\{NEWSA:(\d+):(.*?)\}/e','get_newsa_articles($template_default["news"],$1,$db,"$2");',$content["all"]);
}

// -------------------------------------------------------------

?>
and this code save as file phpwcms_template/inc_script/frontend_init/newsa.php

Code: Select all

<?php 

// find all new articles in active(exluded current article), where categories is active, public, not hidden and not trashed	
function get_newsa_articles($template_default, $max_cnt_links=0, $dbcon, $cat_id="") {
	// find all new articles in active
	$max_cnt_links = intval($max_cnt_links);
	$limit = ($max_cnt_links) ? " LIMIT ".$max_cnt_links : "";

// START MOD
    // check for params
    if ($cat_id === "CURRENT") {
      $cat_id = "'".(int)$GLOBALS['content']['cat_id']."'";
    } else if ($cat_id == "") {
      $cat_id = 'ac.acat_id';
    } else {
      $cat_id = "'".(int)$cat_id."'";
    }
  // fixed bug sql 
	$sql =	"SELECT a.article_id, a.article_title, a.article_cid, UNIX_TIMESTAMP(a.article_tstamp) AS article_date 
	           FROM ".DB_PREPEND."phpwcms_article a, ".DB_PREPEND."phpwcms_articlecat ac
			      WHERE a.article_cid = " . $cat_id  . " 
			        AND ac.acat_hidden = '0'
			        AND ac.acat_public = '1'
			        AND ac.acat_aktiv = '1'
			        AND ac.acat_trash = '0'
			        AND a.article_id != '" . (int)$GLOBALS['content']['article_id']  . "'
			        AND a.article_public = '1' 
			        AND a.article_aktiv = '1' 
			        AND a.article_deleted = '0' 
			        AND a.article_begin < NOW() 
			        AND a.article_end > NOW() 
			   ORDER BY a.article_tstamp DESC".$limit;
// END MOD

	// new articles list
	$new_links = "";
	$target = ($template_default["link_target"]) ? ' target="'.$template_default["link_target"].'"' : "";
	if($result = mysql_query($sql, $dbcon)) {
		$count_results = mysql_num_rows($result); $count = 0;
		while ($row = mysql_fetch_row($result)) {
			$count++;
			if($template_default["link_length"] && strlen($row[1]) > $template_default["link_length"]) {
				$article_title = substr($row[1], 0, $template_default["link_length"]).$template_default["cut_title_add"];
			} else {
				$article_title = $row[1];
			}
			if(trim($template_default["date_format"])) {
				$article_title = international_date_format(
									$template_default["date_language"], 
									$template_default["date_format"], 
									$row[3]).$article_title;
			}
			$new_links .= $template_default["link_before"].$template_default["link_symbol"];
			$new_links .= '<a href="index.php?id='.$row[2].','.$row[0].',0,0,1,0"';
			$new_links .= $target.">".html_specialchars($article_title)."</a>";
			
			//try to remove possible unwanted after - if not enclosed before.link.after
			if($new_links && !$template_default["link_before"] && $count < $count_results) {
				$new_links .= $template_default["link_after"];
			}
		}
		mysql_free_result($result);
	}

	//enclose whole
	if($new_links) $new_links = $template_default["before"].$new_links.$template_default["after"];
	
	return $new_links;
}

?>
now chek vars in conf.inc.php, its is probably like this

Code: Select all

$phpwcms["allow_ext_init"]    = 1;  //allow including of custom external scripts at frontend initialization
$phpwcms["allow_ext_render"]  = 1;  //allow including of custom external scripts at frontend rendering
now {NEWSA} tag worked
usage:
{NEWSA:10} - show last 10 active articles(exluding current article) from all section where categories is active, public, not hidden and not trashed
{NEWSA:10:CURRENT} - show last 10 articles from current section(exluding current article)
{NEWSA:10:_ID_NUMBER_} - show last 10 articles from _ID_NUMBER_ section

good luck

Posted: Mon 17. Jan 2005, 10:01
by monocult
the {newsa} not work for me :-(

i save the fils in

phpwcms_template/inc_script/frontend_render/newsa.php
and
phpwcms_template/inc_script/frontend_init/newsa.php

change the

$phpwcms["allow_ext_init"] = 1; //allow including of custom external scripts at frontend initialization
$phpwcms["allow_ext_render"] = 1; //allow including of custom external scripts at frontend rendering

but in the frontend is only the {newsa} tag :-)

Posted: Mon 17. Jan 2005, 11:56
by frold
I guess you need to use CAPITAL letters like:

{NEWSA:10}

Posted: Mon 17. Jan 2005, 15:40
by monocult
frold wrote:I guess you need to use CAPITAL letters like:

{NEWSA:10}
it doesnt work for me :-(

Posted: Mon 17. Jan 2005, 22:05
by creep
monocult wrote:the {newsa} not work for me
The {newsa} tag not working without parameters, see usage in the top of the code.

B.Regards

Re: {NEWSA} Tag

Posted: Tue 18. Jan 2005, 09:59
by monocult
creep wrote: {NEWSA:10} - show last 10 active articles(exluding current article) from all section where categories is active, public, not hidden and not trashed
{NEWSA:10:CURRENT} - show last 10 articles from current section(exluding current article)
{NEWSA:10:_ID_NUMBER_} - show last 10 articles from _ID_NUMBER_ section
I try {NEWSA:10} {NEWSA:10:CURRENT} and {NEWSA:10:2}

Sub-categories

Posted: Tue 18. Jan 2005, 12:33
by ponsfrilus
Hi, I'm looking for a way to get last news from a categories, including its sub-categories... ?

Posted: Tue 18. Jan 2005, 12:40
by cyrano
If you have defined a keyword in each structure and substructure you will be able to show the latest edited, added or new articles.