front.func.inc.php - related verlinkung ändern

Discuss phpwcms here, please do not post support requests, bug reports, or feature requests! Non-phpwcms questions, discussion goes in General Chat!
Post Reply
mmm
Posts: 70
Joined: Sun 17. Apr 2005, 18:33

front.func.inc.php - related verlinkung ändern

Post by mmm »

hallo allerseits,

ich möchte bei den related-tags die verlinkung ändern, sodass er mir nicht mehr eine ID sondern einen korrekten link ausspuckt. als eingabe verwende ich beim gewöhnlichen article-listing "Caption" als Linkeingabe.

i want to change the link-source into the realated-tags and the article-listing. so i use for the link-source into the article-setup (in backend) the article_caption.

in the article-list script shows:

script hierfür (article-list):

Code: Select all

<div class="listingsub">
	<table border="0" cellpadding="0" cellspacing="0">
		<tr>
			<td width="310" background="http://www.bleibfit.at/picture/headbalken/1.gif">
				<h1 class="articleHead">{SUB}</h1>
			</td>
		</tr>
	</table>
		<a title="{TITLE}" href="{CAPTION}" style="margin:4 5 0 0; float:left">{IMAGE}</a>
		<a title="{TITLE}" href="{CAPTION}">
			<h2 class="articleSubHeadsub">{TITLE}</h2>
			<p class="articleSummarysub">{SUMMARY}
				<span class="articleMore1">mehr</span>
			</p>
		</a>
</div>
there works! the next problem is, to change the link into the related-tags. it should insert the article_caption also!

so i thought, i have to change the "id" to ".$article_caption."

nun muss ich es auch hinbekommen, dass er bei den related-tags NUR "caption" einfügt. doch da kam es zu problemen:

datei: front.func.inc.php: function get_related_articles

bei der verlinkung statt:

Code: Select all

				$keyword_links .= $template_default["link_before"].$template_default["link_symbol"];
				$keyword_links .= '<a title="'.$article_title.'" href="index.php?id='.$row[2].','.$row[0].',0,0,1,0"';
				$keyword_links .= $target.">".html_specialchars($article_title)."</a><br />";
die "id" wurde mit article_caption ausgetauscht:
the "id" is changed by the article_caption:

Code: Select all

				$keyword_links .= $template_default["link_before"].$template_default["link_symbol"];
				$keyword_links .= '<a title="'.$article_title.'" href=".$article_caption."';
				$keyword_links .= $target.">".html_specialchars($article_title)."</a><br />";
doch es funktioniert nicht, habe ich da irgendwo einen denkfehler, oder warum funktioniert es nicht?? das lustige dabei ist, wenn ich die id mit article_title austausche, dann funktioniert es. brauche aber wie gesagt, article_caption und nicht article_title...

ich bitte dringend um hilfe, da ich momentan alle artikel weiterleiten muss und die gefahr dass ich bei google auf die spam-liste komme immens hoch ist...

but it doesn´t work. what should i do? if I change the article_id with the article_title it works!! but not with the article_caption, why??

i hope, somebody can help me...

hier das ganze file im front.func.inc.php: function get_related_articles
here you get the total file into front.func.inc.php: funcion get_related_articles

Code: Select all

function get_related_articles($keywords, $current_article_id, $template_default, $max_cnt_links=0, $dbcon) {
	// find keyword for current article used for RELATED replacementtag
	// prepared and inspired by Magnar Stav Johanssen

	$keyword_links = ""; $max_cnt_links = intval($max_cnt_links);
		
	// replace unwanted chars and convert to wanted
	$keywords = str_replace(";", ",", $keywords);
	$keywords = str_replace("'", "", $keywords);
	$keywords = str_replace(" ", ",", $keywords);
	
	// choose comma separated keywords
	$keywordarray = explode (",", $keywords);
	// check for empty keywords or keywords smaller than 3 chars
	if(sizeof($keywordarray)) {
		foreach($keywordarray as $key => $value) {
			$keywordarray[$key] = trim($value);			
			if(!$keywordarray[$key] || strlen($keywordarray[$key]) < 3) unset($keywordarray[$key]);		
		}
	}

	if(sizeof($keywordarray)) {
		$where = "";
		foreach($keywordarray as $value) {
			//build where keyword = blabla
			$where .= ($where) ? " OR " : "";
			//replace every "'" to "''" for security reasons with aporeplace()
			$where .= "article_keyword LIKE '%".aporeplace($value)."%'";		
		}
		$limit = ($max_cnt_links) ? " LIMIT ".$max_cnt_links : "";
		$sql  =	"SELECT article_id, article_title, article_cid, article_subtitle, article_summary ";
		$sql .=	"FROM ".DB_PREPEND."phpwcms_article WHERE article_deleted=0 AND ";
		$sql .=	"article_id<>".intval($current_article_id)." AND ";
		// VISIBLE_MODE: 0 = frontend (all) mode, 1 = article user mode, 2 = admin user mode
		switch(VISIBLE_MODE) {
			case 0: $sql .=	"article_public=1 AND article_aktiv=1 AND ";
					break;
			case 1: $sql .= "article_uid=".$_SESSION["wcs_user_id"]." AND ";
					break;
			//case 2: admin mode no additional neccessary
		}
		$sql .=	"article_begin < NOW() AND article_end > NOW() AND (".$where.") ";
		$sql .=	"ORDER BY article_tstamp DESC".$limit;

		// related things
		$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];
				}
				$keyword_links .= $template_default["link_before"].$template_default["link_symbol"];
				$keyword_links .= '<a title="'.$article_title.'" href="index.php?id='.$row[2].','.$row[0].',0,0,1,0"';
				$keyword_links .= $target.">".html_specialchars($article_title)."</a><br />";
				
				//try to remove possible unwanted after - if not enclosed before.link.after
				if($keyword_links && !$template_default["link_before"] && $count < $count_results) {
					$keyword_links .= $template_default["link_after"];
				}
			}
			mysql_free_result($result);
		}
	}

	//enclose whole
	if($keyword_links) $keyword_links = $template_default["before"].$keyword_links.$template_default["after"];
	
	return $keyword_links;
}
liebe Grüße aus Wien
best regards from vienna
Manuel
Last edited by mmm on Mon 17. Oct 2005, 14:55, edited 3 times in total.
jscholtysik

Post by jscholtysik »

Hi mmm,


please try to compose your questions in english as well as in german language, because this is an international forum!

Thank you very much in advance.


Joachim
mmm
Posts: 70
Joined: Sun 17. Apr 2005, 18:33

Re: front.func.inc.php - related verlinkung ändern

Post by mmm »

ist nun deutsch/englisch.

lgM
mmm
Posts: 70
Joined: Sun 17. Apr 2005, 18:33

Post by mmm »

nobody cans help me??

b.r.
manuel
mmm
Posts: 70
Joined: Sun 17. Apr 2005, 18:33

Post by mmm »

now i´m using the redirect-line, but it doesn´t work too....

Code: Select all

            $keyword_links .= $template_default["link_before"].$template_default["link_symbol"]; 
            $keyword_links .= '<a title="'.$article_title.'" href="'.$article_redirect.'"'; 
            $keyword_links .= $target.">".html_specialchars($article_title)."</a><br />"; 
b.r.
manuel
mmm
Posts: 70
Joined: Sun 17. Apr 2005, 18:33

Post by mmm »

hat sich erledigt... hier noch die auflösung:

sollte jemand seine related-tags suchmaschinen-sicherer machen wollen,

- neue seite anlegen
- NUR einen artikel darauf anlegen
- bei "weiterleiten" dann die zielurl eingeben (seitenname)

und im front.func.inc.php dann unter "function get_related_articles" diesen code verwenden: dadurch greift er nicht mehr auf die dynamische url zu, sondern auf den redirect (weiterleiten)

Code: Select all

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

function get_related_articles($keywords, $current_article_id, $template_default, $max_cnt_links=0, $dbcon) {
	// find keyword for current article used for RELATED replacementtag
	// prepared and inspired by Magnar Stav Johanssen

	$keyword_links = ""; $max_cnt_links = intval($max_cnt_links);
		
	// replace unwanted chars and convert to wanted
	$keywords = str_replace(";", ",", $keywords);
	$keywords = str_replace("'", "", $keywords);
	$keywords = str_replace(" ", ",", $keywords);
	
	// choose comma separated keywords
	$keywordarray = explode (",", $keywords);
	// check for empty keywords or keywords smaller than 3 chars
	if(sizeof($keywordarray)) {
		foreach($keywordarray as $key => $value) {
			$keywordarray[$key] = trim($value);			
			if(!$keywordarray[$key] || strlen($keywordarray[$key]) < 3) unset($keywordarray[$key]);		
		}
	}

	if(sizeof($keywordarray)) {
		$where = "";
		foreach($keywordarray as $value) {
			//build where keyword = blabla
			$where .= ($where) ? " OR " : "";
			//replace every "'" to "''" for security reasons with aporeplace()
			$where .= "article_keyword LIKE '%".aporeplace($value)."%'";		
		}
		$limit = ($max_cnt_links) ? " LIMIT ".$max_cnt_links : "";
		$sql  =	"SELECT article_id, article_redirect, article_title, article_cid, article_subtitle, article_summary ";
		$sql .=	"FROM ".DB_PREPEND."phpwcms_article WHERE article_deleted=0 AND ";
		$sql .=	"article_id<>".intval($current_article_id)." AND ";
		// VISIBLE_MODE: 0 = frontend (all) mode, 1 = article user mode, 2 = admin user mode
		switch(VISIBLE_MODE) {
			case 0: $sql .=	"article_public=1 AND article_aktiv=1 AND ";
					break;
			case 1: $sql .= "article_uid=".$_SESSION["wcs_user_id"]." AND ";
					break;
			//case 2: admin mode no additional neccessary
		}
		$sql .=	"article_begin < NOW() AND article_end > NOW() AND (".$where.") ";
		$sql .=	"ORDER BY article_tstamp DESC".$limit;

		// related things
		$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_redirect = $row[1];
					$article_title = $row[2];
				}
				$keyword_links .= $template_default["link_before"].$template_default["link_symbol"];
				$keyword_links .= '<a title="'.$article_title.'" href="'.$article_redirect.'"';
				$keyword_links .= $target.">".html_specialchars($article_title)."</a><br />";
				
				//try to remove possible unwanted after - if not enclosed before.link.after
				if($keyword_links && !$template_default["link_before"] && $count < $count_results) {
					$keyword_links .= $template_default["link_after"];
				}
			}
			mysql_free_result($result);
		}
	}

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

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

hier nochmal die auflösung:

Code: Select all

					$article_redirect = $row[1];
					$article_title = $row[2];
				}
				$keyword_links .= $template_default["link_before"].$template_default["link_symbol"];
				$keyword_links .= '<a title="'.$article_title.'" href="'.$article_redirect.'"';
				$keyword_links .= $target.">".html_specialchars($article_title)."</a><br />";
Post Reply