Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Topic closed
#1 2004-06-08 20:59:14
- Remillard
- Plugin Author
- From: Lenexa, KS
- Registered: 2004-05-16
- Posts: 169
[archived] mdn_sectionlink
Notice: this thread is archived, see <txp:section>
***************************************
Well this one is handy to me, and I think I’ve seen a few questions about if something like this was available. I poked around and didn’t find it so wrote it myself.
The tags are placed around your link text and allows you to select by section, the link destination.
From the help text:
<p>This tag takes one parameter: section. If this parameter is not present, the default will be the current section in the context of the page.</p>
<p>
<code>
Usage:<br/>
<txp:mdn_sectionlink [section=\“sectionname\”]> Link Text </txp:mdn_sectionlink>
</code>
</p>
You can grab the plugin from here: mdn_sectionlink.txt.
Let me know if you have any problems.
Regards,
Remillard
Last edited by els (2009-04-24 17:43:13)
Offline
Re: [archived] mdn_sectionlink
I made the following little tweaks to your script:
==<pre>
function mdn_sectionlink($atts, $enclosed = ‘’) {
….
$enclosed = (empty($enclosed)) ? $section : $enclosed;
….
}
function mdn_articlesectionlink($atts) {
global $thisarticle;
if ( !is_array($atts) || !isset($thisarticle) )
return;
$atts[‘section’] = $thisarticle[‘section’];
return mdn_sectionlink($atts, $thisarticle[‘section’]);
}
</pre>==
To allow use of an empty tag: <mdn_sectionlink /> that will create a link to the current section using the section name, and further, to allow the creation of the section associated with an article by the same means…
There may already be an easier way to do this (let me know if so) but I found those additions to be helpful. Feel free to incorporate.
;)
Last edited by ebullient (2005-01-11 05:45:38)
‘Waste of a good apple.’ – Samwise Gamgee
Offline
#3 2005-01-11 08:34:28
- Remillard
- Plugin Author
- From: Lenexa, KS
- Registered: 2004-05-16
- Posts: 169
Re: [archived] mdn_sectionlink
Nifty mod.
It might be some time before I get a chance to incorporate but I believe I will. We’ve just got lots of things going on (family medical stuff, new job, buckets of rain, Mac crashes, Linux happiness, Windows usual stuff, more medical stuff…etc.) so I haven’t done anything Textpatternish for almost a month (sorry Destry, it’ll be a little while longer.)
Remillard
Offline
Re: [archived] mdn_sectionlink
I tried this plugin and extended it with support for messy URLs (since they are still factory default), taken from the permlink tag. It now looks like this:
<pre>
<code>
function mdn_sectionlink($atts, $enclosed) {
// This function takes the parameter section and creates
// a link using the enclosed portion as the text for the
// link.
if (is_array($atts)) extract($atts);
global $pretext;
extract ($pretext);
$section = (empty($section)) ? $GLOBALS[‘s’] : $section;
$enclosed = (empty($enclosed)) ? $section : $enclosed;
$url = safe_row(“val”,“txp_prefs”,“name=‘siteurl’”); extract ($url);
global $pfr,$url_mode; $out = ($url_mode==1) ? $pfr.$section.’/’ : $pfr.‘index.php?s=’.$section;
return “<a href=\“http://”.$val.$out.”\”>”.$enclosed.”</a>”;
}
</code>
</pre>
Maybe someone finds this helpful.
Thomas
Last edited by thomasstache (2005-01-18 19:25:52)
Thomas Stache
Offline
Pages: 1
Topic closed