Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2005-04-22 22:40:43

rdtietjen
Archived Plugin Author
Registered: 2005-03-04
Posts: 31
Website

Re: [plugin] [ORPHAN] rdt_dynamenus - automatic section and article menus

> marios wrote:

> I am experimenting with rdt_dynamenus for my news site template.
Well it perfectly suits my needs,I have a question about this.
I am using the rdt_article menu tag for my sidelinks.Well everything works precisely as expected and exactly the way I had planned it except one thing.
For each article sidelink I would like to display an excerpt summary of the corresponding article(not more then 25 words count)below each link and allso be able to apply a class to it.)
> Because I’m new to textpattern I’ll ask first this:Is that something that I could achieve in combination with existing TXP tags,or does the plug in need to be hacked in to allow excerpts.
> (Basically from generated XHTML that would make more sense then with definition lists.)
> It would be nice to see this wunderfull plug in with more features,
Is there any hack technique that can be used?

marios,

The article menu plugin begin life as a derivation of chh_article_custom. chh_article_custom has lots of nice features including what you want: the ability to pass in a form to show the article information. On the other hand, chh lacked active class marking and switched to single article display when not at the section level.

My initial plugin simplified chh so I could send you my initial code to hack. I switched to the current code because it was easier to document and it followed the prevailing idiom of similar plugins. Or you could hack the current code to accept an optional form parameter, I suppose. I’ll keep the idea in mind.


TV? Buglight for humans.

Offline

#26 2005-04-22 22:54:52

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: [plugin] [ORPHAN] rdt_dynamenus - automatic section and article menus

Thanks for your explanation and advise rdtietjen.One question:
What would be the basic differnce betwween the initial code and the download code in short, just so I may understand what you explain?


⌃ ⇧ < ⌃ ⇧ >

Offline

#27 2005-04-24 21:14:17

jpdupont
Member
Registered: 2004-10-01
Posts: 752

Re: [plugin] [ORPHAN] rdt_dynamenus - automatic section and article menus

Is it possible to improve this plugin with section alias , to be allowed to use (french or others) accentuated chars in section links ?

Offline

#28 2005-04-25 09:14:31

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,729
Website

Re: [plugin] [ORPHAN] rdt_dynamenus - automatic section and article menus

Hi jpdupont,

The problem is that TXP converts all accents to written out charstrings for the article url and these are then displayed on the site i.e. incorrectly for the language. I made a fairly inelegant hack to the plug-in for German for converting back the charstring to a correctly displayed German name. There may well be a better approach.

At the time I was working on a dual language setup and had named all my sections with a prefix “de-sectionname” or “en-sectionname” so I added an input variable for the plugin called “langprefix”. Again this prefix needed stripping out for the menu.

I only needed rdt_section_menu. This is what I changed.

1. in the variables array near the top of the rdt_section_menu function [ extract(lAtts(array( … ] I added an additional line as follows before the closing [ ),$atts)); ] <pre> ‘langprefix’ => ‘’, // new langprefix variable
</pre>

2. A bit further down before the following string: <pre> $content = preg_replace(“/-/”,”&nbsp;”,$content); $content = ucwords($content);
</pre>

I added

<pre> if (!empty($langprefix) and $langprefix 'en') { $content = preg_replace("/en-/","",$sectionname); } if (!empty($langprefix) and $langprefix ‘de’) { $content = preg_replace(“/de-/”,”“,$sectionname); $content = ucwords($content); $content = preg_replace(“/ae/”,”&#228;”,$content); $content = preg_replace(“/oe/”,”&#246;”,$content); $content = preg_replace(“/ue/”,”&#252;”,$content); $content = preg_replace(“/Ae/”,”&#196;”,$content); $content = preg_replace(“/Oe/”,”&#214;”,$content); $content = preg_replace(“/Ue/”,”&#220;”,$content); $content = preg_replace(“/sz/”,”&#223;”,$content); } </pre>

You will need to change the search and replace strings for the French equivalents depending upon how they have been written out (that is if that is at all possible). The first line with prefix replacement you may not need as that was just my setup, likewise if you don’t want capitalised names then the second ucwords you will also not need.

If charstrings cannot be converted back for French because they are no longer discernably different from their normal appearance (in German it’s a little easier) maybe the approach with section aliases would work better for you where you define equivalent strings for your section URLs.

….

I also made some further hacks, though these aren’t directly related to the language thing

3. to work with a subdirectory install of TXP I changed the variable $pfr into hu. The URLs It generates are then absolute URLs. This works for a whole variety of plug-ins now that the path-from-root $pfr is deprecated and removed from the admin panel.

4. AFAIK the underscore “_” is no longer allowed in section names, but the – is used for a space. I changed the line:

<pre> $content = preg_replace(“/_/”,”&nbsp;”,$content); </pre>

into

<pre> $content = preg_replace(“/-/”,”&nbsp;”,$content); </pre>

TXP Builders – finely-crafted code, design and txp

Offline

#29 2005-04-25 09:20:31

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,729
Website

Re: [plugin] [ORPHAN] rdt_dynamenus - automatic section and article menus

can’t edit the above post so please note: all the above applies to RC3.
Secondly textile changes some of the code above. The quotes are all normal straight quotes and the replaced characters were expressed as their &# entities.


TXP Builders – finely-crafted code, design and txp

Offline

#30 2005-04-25 13:52:35

jpdupont
Member
Registered: 2004-10-01
Posts: 752

Re: [plugin] [ORPHAN] rdt_dynamenus - automatic section and article menus

Thanks jakob,

I try this on RC3.

Your hack is not usefull with french : in sections, école give -> ecole.

I need here true alias approach ….

BTW, I don’t understand “hu” here : …TXP I changed the variable $pfr into hu…

Offline

#31 2005-04-25 15:20:07

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,729
Website

Re: [plugin] [ORPHAN] rdt_dynamenus - automatic section and article menus

well, I’m no expert on this but I’ve found that when developing txp site offline, with each in a subdirectory of their own, many of the plug-ins no longer output a correct URL in RC3. The subdirectory is omitted. There’s no problem if it’s not in a subdirectory.
In RC2 everything worked as you could add the subdirectory in the admin panel. In RC3 the option was taken out (tho’ I believe you can add it by hand to the admin config) and the $pfr path-from-root variable deprecated. However, lots of plug-ins still use it.

If you don’t have this problem, then it’s not important for you.

My home-baked way of solving the problem was to change all occurrences of $pfr into hu, for example where it says $pfr.$section it now says hu.$section. A simpler way turned out to be adding a line directly beneath the definition of global variables, almost always in the first lines of a plug-in: <pre>
$pfr = hu;
</pre>

hu is the global variable for the definitive http address of the site. (see the comments in publish.php) so basically it forces absolute links to be generated including subdirectory.


TXP Builders – finely-crafted code, design and txp

Offline

#32 2005-04-25 18:20:32

jpdupont
Member
Registered: 2004-10-01
Posts: 752

Re: [plugin] [ORPHAN] rdt_dynamenus - automatic section and article menus

:) Thanks ! I understand now !

Offline

#33 2005-04-27 21:59:52

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: [plugin] [ORPHAN] rdt_dynamenus - automatic section and article menus

Wouldn’t it be good if one could actually display a specified range of sections in the ul like in mdp_section menu ?
I mean so you can exclude sections.

regards, marios


⌃ ⇧ < ⌃ ⇧ >

Offline

#34 2005-04-29 06:32:41

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,729
Website

Re: [plugin] [ORPHAN] rdt_dynamenus - automatic section and article menus

marios,

if you use the order parameter, everything that is not included in the list is left out.

general comment:not sure if I have understood this correctly but RC3 changeset 326 adds a new title field for categories and sections to the database. I hope this is the solution for all those foreign name problems and converting back and forth acrobatics above. Maybe then alias workarounds are a thing of the past as they are now stored directly in the database.
As far as I know they are not editable from the admin like URL-title so the question of their order is still an issue.


TXP Builders – finely-crafted code, design and txp

Offline

#35 2005-04-29 12:28:10

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: [plugin] [ORPHAN] rdt_dynamenus - automatic section and article menus

jakob,I just reverted back to rdt_dynamenus(great plugin) and it let’s you actually exclude a range of sections, in the section_menu tag something that I probably had missed before.So the problem is solved for now.
So in one of my page temlates it looks like this:

<code>
<txp:rdt_section_menu wraptag=‘ul’ break=‘li’ class=‘menu’ active=‘active’ id=‘sections’ noshow=‘houston,news,weird’ home=‘home’ order=’‘ />
</code>
I’m on revision 328 and it works great.


⌃ ⇧ < ⌃ ⇧ >

Offline

Board footer

Powered by FluxBB