Content part Anchor links

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply
User avatar
pSouper
Posts: 1552
Joined: Tue 11. Nov 2003, 15:45
Location: London
Contact:

Content part Anchor links

Post by pSouper »

Hi all,
This is a hack to the core and so sould be use with causion.

What does it do?
This hack inserts an invisible anchor link between a content parts 'before' spacer and the content parts main body. the anchor is simply named the content parts ID number visible here...
Image

Why does it do that?
so that you may jump to specific article content parts rather than just pages as at present.

How do I use it to jump to a contentpart within the current page?
You can either use phpwcms's default hyperlinking replacement tags... [INT #contentpart id]link name[/INT]
[EXT #contentpart id]link name[/EXT]
or phpwcms's content part: link list
or you can create an html anchor tag... <a href ="#contentpart id">link name</a>[/img]

To use it to jump from one article to a specific anchor within another article you use it as follows...
[INT index.php?articleID#contentpartID]Jump to contentpart x[/INT]
[EXT index.php?articleID#contentpartID]Jump to contentpart x[/EXT]
<a name="#44">Jump to content part x</a>

No, Really, how do I use it?
to jump within the same article you simply use it as follows...
[INT #44]Jump to contentpart 44[/INT]
[EXT #44]Jump to contentpart 44[/EXT]
<a name="#44">Jump to content part 44</a>

To use it to jump from one article to a specific anchor within another article you use it as follows...
[INT index.php?about#44Jump to article with the alias: 'about', content part id: 44[/INT]
[EXTindex.php?about#44Jump to article with the alias: 'about', content part id: 44[/EXT]

you get the idea

what do i do?
copy the following code in to phpwcms_root/include/inc_front/content.article.inc.php at line 337...

Code: Select all

//[pSouper] to be placed at original line 337
				//insert anchor between the article 'before space' and the content part's body
				$CNT_TMP .= '<a name="'.$crow["acontent_id"].'"></a>';
//[/pSouper]
so the local doe now reads...

Code: Select all

				// every article content  will be rendered into temp var 
				$CNT_TMP = '';

				// Space before
				if($crow["acontent_before"]) {
					if(!empty($template_default["article"]["div_spacer"])) {
						$CNT_TMP .= '<div style="margin:'.$crow["acontent_before"].'px 0 0 0; padding:0 0 0 0; clear:both;"></div>';
					} else {
						$CNT_TMP .= "<br>".spacer(1,$crow["acontent_before"]);
					}
				}
//[pSouper] to be placed at original line 337
				//insert anchor between the article 'before space' and the content part's body
				$CNT_TMP .= '<a name="'.$crow["acontent_id"].'"></a>';
//[/pSouper]
				// include content part code section
				include("include/inc_front/content/cnt".$crow["acontent_type"].".article.inc.php");

				//check if top link should be shown
				if($crow["acontent_top"]) {
					if($template_default["article"]["top_sign_before"].$template_default["article"]["top_sign_after"]) {
						$CNT_TMP .= $template_default["article"]["top_sign_before"];
						$CNT_TMP .= '<a href="#top">'.$template_default["article"]["top_sign"].'</a>';
						$CNT_TMP .= $template_default["article"]["top_sign_after"];
					} else {
						$CNT_TMP .= '<br><a href="#top">'.$template_default["article"]["top_sign"].'</a>';
					}
				}

				// Space after

have fun, hope it's useful to someone, hope it gets into a release candidate :)
User avatar
pSouper
Posts: 1552
Joined: Tue 11. Nov 2003, 15:45
Location: London
Contact:

{JUMPCP} 'Jump to article & content part' replacement ta

Post by pSouper »

For those who like to use repacement tags you may use this one in conjunction with this hack to jump from anywhere in the site to a specific article & content part...

If you don't already have your own replacement tags file in phpwcms_template/inc_script/frontend_render/ (which i recommend you do) you should read this thread

and construct the following...
repacement tag
Post Reply