Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#193 2006-02-23 22:19:24

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: mem_glinklist: Grouped Link List

Well, Manfre, I finally find the solution in the code of the plug-in

There is a part of the plug-in code that is:

<pre><code>
// Remove the next three ‘//’ to enable clean urls
// if ($permlink_mode==‘messy’ or $argname==‘lc’) $href = $baseurl . ‘?’.$argname.’=’.urlencode($parent[‘name’]);
// else
// $href = $baseurl . ‘category/’.urlencode($name);

if (empty($thing)) $thing = $parent[‘title’];

return tag(str_replace(“& “,”& “, $thing),‘a’,’ href=”’.$href.’” title=”’.$parent[‘title’].’”’);
}

function mem_cat_link($atts,$thing=’‘)
{ global $permlink_mode,$thiscategory;

extract(lAtts(array( ‘class’ => FUNCTION, ‘argname’ => ‘’, ‘baseurl’ => hu ),$atts)); extract($thiscategory);

if (!isset($argname) or empty($argname)) { $argname = ($type==‘link’) ? ‘lc’ : ‘c’; }

// Remove the next three ‘//’ to enable clean urls if ($permlink_mode==‘messy’ or $argname==‘lc’) $href = $baseurl . ‘?’.$argname.’=’.urlencode($name); else $href = $baseurl . ‘category/’.urlencode($name);

if (empty($thing)) $thing = $title;

return tag(str_replace(“& “,”& “, $thing),‘a’,’ href=”’.$href.’” title=”’.$title.’”’);
}</code></pre>

So, I commented the last chunk, in this way:

<pre><code>
// Remove the next three ‘//’ to enable clean urls
// if ($permlink_mode==‘messy’ or $argname==‘lc’) $href = $baseurl . ‘?’.$argname.’=’.urlencode($name);
// else
// $href = $baseurl . ‘category/’.urlencode($name);

if (empty($thing)) $thing = $title;

return tag(str_replace(“& “,”& “, $thing),‘a’,’ href=”’.$href.’” title=”’.$title.’”’);
}</code></pre>

And now, my urls, when using argname="c", are outputted as expected.
And the “filter by category” links (mem_categories) are working as expected with m_glinklist.

Thanks for your patience.

Last edited by maniqui (2006-02-27 21:41:43)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#194 2006-04-06 00:19:41

tinyfly
Member
From: Dallas, Texas
Registered: 2004-05-10
Posts: 462
Website

Re: mem_glinklist: Grouped Link List

manfre, I have a feature request. Could you add an attribute like showchildren? That way I could specify a top level category and your plugin would generate a list from all child categories also.

What do you think?

Offline

#195 2006-04-07 19:13:59

obley
New Member
From: Champaign, IL
Registered: 2006-04-07
Posts: 7
Website

Re: mem_glinklist: Grouped Link List

tinyfly wrote:

manfre, I have a feature request. Could you add an attribute like showchildren? That way I could specify a top level category and your plugin would generate a list from all child categories also.
What do you think?

yea… I jsut read all 8 pages looking for this exact feature. What I am looking for is a display of all links in the specified category plus child categories while never displaying sibilings or parents.

That would be super sweet.

make sense?

Offline

#196 2006-04-07 20:25:25

obley
New Member
From: Champaign, IL
Registered: 2006-04-07
Posts: 7
Website

Re: mem_glinklist: Grouped Link List

ok, so I’ve poked around and forced a solution until Manfre makes a better one, if he deems worthy.

(made a better solution in my next post…)
on line 431 of version .8.5 you will find the mem_get_all_categories() function. Just replace ‘root’ with the catagory name you want to act as root.

I’ve noticed that this will not display links from that catagory, only links in child catagories. I’m cool with that since I intened to keep my links organized in such a fashion. This also still displays links in the root catagory as unclassified but that can be disabled with already existing attributes.

I woudl like to make a “catroot” attribute so the catagory root can be changed dynamically but don’t know php well enough to swing it. I’ll keep cracking at it unless someone tells me I’m way off or offers a better solution.

Thanks Manfre, lov’n it!

Last edited by obley (2006-04-12 01:44:13)

Offline

#197 2006-04-12 02:25:53

obley
New Member
From: Champaign, IL
Registered: 2006-04-07
Posts: 7
Website

Re: mem_glinklist: Grouped Link List

ok, I’ve modified a function and its call to create a dynamic “root” and it works pretty well for me.

This accepts a new variable called catroot holdint the value of the catagory you want to be the base. It still lists all loose tags in root and I’m not sure how to get it to stop that.

what I changed….

lines 66 and 67 become this:
<pre><code> ‘catform’ => ‘’, ‘catroot’ => ‘root’
</code></pre>

line 79:
<pre><code> $cats = mem_get_all_categories(‘link’, $catroot);
</code></pre>

line 431:
<pre><code>
function mem_get_all_categories($type, $root)
</code></pre>

line 436:
<pre><code> $rs = getTree($root,$type);
</code></pre>

and finally line 441:
<pre><code> $out[‘name’][] = ($name==$root?’‘:$name);
</code></pre>

You can see this in action with two seperate trees using different roots here and eventually over there

Offline

#198 2006-04-21 21:57:55

viewchange
New Member
Registered: 2005-07-30
Posts: 5

Re: mem_glinklist: Grouped Link List

Link Wrap Tag

I wanted a way to wrap each link of the listing with a tag such as li. I confess I didn’t read all the pages of this post. Perhaps the plugin does it natively or there is a better way to do this? I suppose you could just include the tag in the link form (this didn’t occurr to me until after modding the plugin).

Anyhow, I added the attributes linkwraptag and linkclass

Around line 50…

<code> extract(lAtts(array( ‘category’ => ‘’, ‘columns’ => ‘1’, ‘form’ => ‘’, ‘limit’ => ‘0’, ‘sort’ => ‘linksort’, ‘headless’ => false, ‘uncategorized’ => ‘Uncategorized’, ‘linkwraptag’ => ‘li’, ‘listwraptag’ => ‘ul’, ‘headwraptag’ => ‘div’, ‘columnwraptag’ => ‘div’, ‘linkclass’ => ‘mem_link’, ‘listclass’ => ‘mem_list’, ‘headclass’ => ‘mem_list_head’, ‘columnclass’ => ‘mem_list_column’, ‘sortbycat’ => false, ‘argname’ => ‘’, ‘catform’ => ‘’ ),$atts));
</code>

And later in the file around line 160…

<code> foreach ($slice as $l) { extract($l);

$surl = htmlspecialchars($url); $link = ‘<a href=”’.$surl.’”>’.$linkname.’</a>’; $linkdesctitle = ‘<a href=”’.$surl. ‘” title=”’.$description.’”>’.$linkname.’</a>’;

$cl = $Form;

$cl = str_replace(“<txp:link />”, $link, $Form); $cl = str_replace(“<txp:linkdesctitle />”, $linkdesctitle, $cl); $cl = str_replace(“<txp:link_description />”, $description, $cl);

//added linkwraptag $cl = doTag($cl,$linkwraptag,$linkclass).n;

$GLOBALS[‘thislink’] = $l; $col_out .= parse($cl); unset($GLOBALS[‘thislink’]); }
</code>

Hope someone finds it useful.

Brian

Offline

#199 2006-04-22 01:56:15

obley
New Member
From: Champaign, IL
Registered: 2006-04-07
Posts: 7
Website

Re: mem_glinklist: Grouped Link List

viewchange, this could have been done without code manipulation using a form.

This is how I acomplish the very same thing:

<code><txp:mem_glinklist form=“Links” columnwraptag=“ul” uncategorized=”&nbsp;” catroot=“linkage” listclass=“linkage” /></code>

and then the form links contains:

<code><li><txp:linkdesctitle /><span><txp:link_description /></span></li></code>

but I understand that sometimes its just more fun to mess with the source code ;)

Offline

#200 2006-04-24 12:56:12

viewchange
New Member
Registered: 2005-07-30
Posts: 5

Re: mem_glinklist: Grouped Link List

obley — good point, wasn’t until after messing with the code that I realized it could be done via the form. Oh well. Though it was a good primer to the world of TXP plugins!

-Brian

Offline

#201 2006-10-06 00:13:13

tameboy
Plugin Author
Registered: 2006-06-29
Posts: 48

Re: mem_glinklist: Grouped Link List

obley – your modification to this plugin seems to be just what I was looking for. However, I don’t understand how you are organising your links into parent and child categories in the first place. As far as I can see you can only have one category for each link.

I want to have a section on a site I am developing which would be very similar to what you have on http://sandbox.obleys.net/linkage.

Any help/explanation gratefully received.

Offline

#202 2006-10-07 03:57:12

obley
New Member
From: Champaign, IL
Registered: 2006-04-07
Posts: 7
Website

Re: mem_glinklist: Grouped Link List

I’m not sure I understand your question. I’m not trying to map a link to several categories, rather two groups of links with sub categories. And the real deal is live, you can see my final organization here even though the site is suffering from serious neglect these days.

screen shot of my links admin section

Maybe that will help shed some light. What ever I throw in the “linkage” category will show up on my page of links. Anything I organize in the “main” category ends up on every page in a margin link list.

To my disipointment, recursive categories only show up in one dimension. For example, the “Fonts and Such” category should be a child of “web design” but the page diasplays it as a sibling. Not that big a deal.. or I would have fixed it already.

Does that explain better what I am doing?

Last edited by obley (2006-10-07 04:01:32)

Offline

#203 2006-10-10 17:01:22

tameboy
Plugin Author
Registered: 2006-06-29
Posts: 48

Re: mem_glinklist: Grouped Link List

Obley, I have sorted my problem. Thanks for your modification to this extension, it has really helped my site.

Another thing I have added is a named anchor along site each category title, so that you can link from another page to a specific category of links. It also enables you to cross reference other categories from within the links list. At the end of function mem_glinklist if you find:

if (!$headless) {
&nbsp;&nbsp;&nbsp;&nbsp; $c_out .= doTag($hd,$headwraptag,$headclass).n;
}

and change it so it reads:

if (!$headless) {
&nbsp;&nbsp;&nbsp;&nbsp; $c_out .= "<a id=\"".strtolower($c)."\" ></a>";
&nbsp;&nbsp;&nbsp;&nbsp; $c_out .= doTag($hd,$headwraptag,$headclass).n;
}

you get an anchor identifying the location of that category title. So if you have a category “Lots More Links”, you can link to this directly with the url mysite.com/linkspage#lots-more-links

Hope someone finds that useful.

NB I should just point out that this only works in Obley’s modification!

Last edited by tameboy (2006-10-11 09:27:37)

Offline

#204 2006-10-15 22:48:53

tameboy
Plugin Author
Registered: 2006-06-29
Posts: 48

Re: mem_glinklist: Grouped Link List

I’ve made some further additions to this extension on a site I am developing for a client. The links page using this extension will have a long list of links in different categories. To enable easier navigation I have placed an alphabetical navigation tool at the top of the page which links to anchors to corresponding alphabetically grouped link categories.

This image probably shows what I am not doing very well at explaining:

<img src=“http://i46.photobucket.com/albums/f131/mikeysmall/brookmill.jpg” border=“0” alt=“Photobucket – Video and Image Hosting”>

I’ve not posted the code changes here but if anyone is interested I could send them on.

Offline

Board footer

Powered by FluxBB