{NEWCATID}

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
rk
Posts: 162
Joined: Sat 24. Apr 2004, 23:48
Location: Hannover, Germany
Contact:

Post by rk »

What did you think about

Code: Select all

{NEW:max_count_links}	
Shows headline and date of last edited article 

Example: {NEW:5} - shows the last edited articles with headline and date
:D
Ralf
nichri
Posts: 8
Joined: Sun 11. Jul 2004, 15:39

Post by nichri »

rk wrote:What did you think about

Code: Select all

{NEW:max_count_links}	
Shows headline and date of last edited article 

Example: {NEW:5} - shows the last edited articles with headline and date
:D
I am not sure if I understand with your question.
nichri
rk
Posts: 162
Joined: Sat 24. Apr 2004, 23:48
Location: Hannover, Germany
Contact:

Post by rk »

nichri wrote: I am not sure if I understand with your question.
You modify a hack for a function you need

Code: Select all

use it like {NEWALL:no_of_latest_articles_to_be_shown} i.e. {NEWALL:10} gets the latest 10 articles from the whole site.
But that function already exist.

If you use {NEW:10} the result is the same, but it is a build in function :-).
Ralf
nichri
Posts: 8
Joined: Sun 11. Jul 2004, 15:39

Post by nichri »

rk wrote: You modify a hack for a function you need

Code: Select all

use it like {NEWALL:no_of_latest_articles_to_be_shown} i.e. {NEWALL:10} gets the latest 10 articles from the whole site.
But that function already exist.

If you use {NEW:10} the result is the same, but it is a build in function :-).
:lol: I didn't know that; I started using phpwcms just a couple of weeks ago and I am still in seek of the rest of its power - obviously I need more reading in the forums.
thnx
nichri
User avatar
isac
Posts: 410
Joined: Tue 18. Nov 2003, 13:13
Location: Portugal
Contact:

Post by isac »

Hello!

I removed this lines

Code: Select all

         if(trim($template_default["date_format"])) {
            $article_title = international_date_format(
                           $template_default["date_language"],
                           $template_default["date_format"],
                           $row[3]).$article_title;
         }
because I don't want to show dates before links, and it work! But I want to know if I have to remove some more code lines?

Thanks,
ISac
User avatar
isac
Posts: 410
Joined: Tue 18. Nov 2003, 13:13
Location: Portugal
Contact:

Re: {NEWCATID}

Post by isac »

oops wrote:headlines from category

Code: Select all

function get_new_articles_from_catid($template_default, $max_cnt_links=0, $cid=0, $dbcon) {
	// find all new articles

	$max_cnt_links = intval($max_cnt_links);
	$limit = ($max_cnt_links) ? " LIMIT ".$max_cnt_links : "";

	$sql =	"SELECT article_id, article_title, article_cid, UNIX_TIMESTAMP(article_tstamp) AS article_date ".
			"FROM ".DB_PREPEND."phpwcms_article WHERE ".
			"article_cid='$cid' AND article_public=1 AND article_aktiv=1 AND article_deleted=0 AND ".
			"article_begin < NOW() AND article_end > NOW() ".
			"ORDER BY article_tstamp DESC".$limit.";";

	// 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;
}

Code: Select all

if( ! ( strpos($content["all"],'{NEWCATID:')===false ) ) {
	$content["all"] = preg_replace('/\{NEWCATID:(\d+):(\d+)\}/e','get_new_articles_from_catid($template_default["news"],$1,$2,$db);',$content["all"]);
}
replacement tag: {NEWCATID:max_count_links:cid}
oops, are you there? :D

Can you make this with highlighting the currently selected position in the list by using a different style.
ndtoan13
Posts: 29
Joined: Wed 16. Mar 2005, 05:11
Contact:

Post by ndtoan13 »

nichri, what is the difference of your tag {NEWALL:..} with default tag {NEW:number} of phpwcms!
User avatar
isac
Posts: 410
Joined: Tue 18. Nov 2003, 13:13
Location: Portugal
Contact:

Post by isac »

ndtoan13 wrote:nichri, what is the difference of your tag {NEWALL:..} with default tag {NEW:number} of phpwcms!
there is no diference. nichri build {NEWALL:..} because he didn't know {NEW:}already exists wich as the same funtion.
snezko
Posts: 21
Joined: Fri 11. Mar 2005, 18:33
Location: Wien
Contact:

new improve ?

Post by snezko »

is it possible change the second variable in this tag by something more dynamic ? for example CURRENT how is it in menu ?

because than i need only one implementation of tag in the template for all the web.
many thanks Snezko
brans

Post by brans »

Hi you all, could all of you, who develop future hacks please quickly read through our guidelines ?

--...--/index.php/topic,4.0.html

please specially mind the frontend_render thing!
Jakim José
Posts: 77
Joined: Fri 18. Feb 2005, 18:55
Location: Portugal/Aveiro

Space between date and title

Post by Jakim José »

How to create a space (&nbsp;) between date and article title?
Jakim José
Posts: 77
Joined: Fri 18. Feb 2005, 18:55
Location: Portugal/Aveiro

Post by Jakim José »

How to place last articles only in homepage. Not in template.
Where I place {NEWCATID:100:5}, for example?
plushett
Posts: 14
Joined: Thu 16. Jun 2005, 02:38
Location: San Francisco, California

pictures?

Post by plushett »

This is very handy, but what about stepping a bit closer to having title with the picture from the article?
Chrismuc
Posts: 15
Joined: Sun 5. Jun 2005, 22:25

Post by Chrismuc »

Hi,
i installed it and it works but there is the space missing inbetween the date
and the headline. how can i change it?

it look like that:
2005/06/18blablabla
2005/06/18testetstets
User avatar
isac
Posts: 410
Joined: Tue 18. Nov 2003, 13:13
Location: Portugal
Contact:

Post by isac »

in conf.template_default.inc.php

Code: Select all

// new articles
$template_default["news"]["before"]			= "<div class=\"news\">";
$template_default["news"]["after"]			= "</div>";
$template_default["news"]["link_before"]	= "";
$template_default["news"]["link_after"]		= "<br>";
$template_default["news"]["link_symbol"]	= "";
$template_default["news"]["link_target"]	= "";
$template_default["news"]["link_length"]	= 0; //if 0 no limit
$template_default["news"]["cut_title_add"]	= "…";
$template_default["news"]["date_language"]	= "EN"; // DE=German, IT=Italian, FR=French, ES = Spanish, DA = Danish, NO = Norwegian
$template_default["news"]["date_format"]	= "Y/m/d"; //if empty -> no Date
$template_default["news"]["date_before"]	= '<span class="datelink">';
$template_default["news"]["date_after"]		= ' - </span>';
$template_default["news"]["date_before"] = '<span class="datelink">';
$template_default["news"]["date_after"] = '
- </span>';
Post Reply