tags?

19 posts by 4 authors in: Forums > CMS Builder
Last Post: June 1, 2009   (RSS)

Re: [ross] tags?

By Toledoh - May 25, 2009

Hi Ross,

Bring it on! As before, I'd rather learn the ins and outs than have it done for me.

Cheers,
Cheers,

Tim (toledoh.com.au)

By ross - May 27, 2009

Hi Tim

Sounds good. Could you post a copy of your test page so I can see all the code you are using? If you wouldn't mind attaching the file instead of just pasting code, that will make it much easier to work with.

Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] tags?

By Toledoh - May 29, 2009 - edited: May 29, 2009

Hi Ross,

File attached - however it's pretty convoluted, maybe we should just use a simple demo page that hasn't got my styles and js links?

Cheers,
Tim
Cheers,

Tim (toledoh.com.au)
Attachments:

posts.php 3K

By willbegood - May 31, 2009

Hello Toledoh, i have done exactly the same thing... perhaps i can help.
contact me on moolood@gmail.com [;)]

By ross - June 1, 2009

Hi there.

I'll work on some code for you this afternoon. I might need until tomorrow to test it all out. I also like the idea of going with a simple version to get a feel for it. I like having a copy of your whole page though just so I can see what variable names you have :).

If willbegood beats me to the punch, let me know.

Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] tags?

By Toledoh - June 1, 2009

Hi Ross,

Still need your help here :)

Willbegood had the same initial thoughts as me... a separate table of tags that was referenced via a pulldown or radio buttons. However I need something that editors can add to on the fly. Also, a separate table may end up with hundreds of values that will become untidy...

Look forward to the next instalment.

Cheers,
Cheers,

Tim (toledoh.com.au)

By Dave - June 1, 2009

Hi Toledoh,

Using another table is a great approach (application design wise) but would require a lot of custom code. If you're not going to have too many records then you can just loop over them all and get a list of all tags and the counts like this:

<?php

// example: use getRecords() to load all records from your section
$records[] = array('tags' => 'one,two, three');
$records[] = array('tags' => 'three,four, five');

// loop over all records and get tag counts
$allTags = array();
foreach ($records as $record) {
$tags = explode(',', $record['tags']);
foreach ($tags as &$tag) {
$tag = trim($tag); // remove leading/trailing whitespace
$tag = strtolower($tag); // lowercase
@$allTags[$tag]++;
}
}

// show contents of $allTags
print "<xmp>";
print_r($allTags);
print "</xmp>";


This is getting pretty advanced PHP wise, so we can't offer too much support on it, but hopefully this will point you in the right direction.

Hope that helps! Let me know if you have any other questions about this.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] tags?

By Toledoh - June 1, 2009

Hi Dave / Ross,

Thanks a bunch! Yet again you've come through for me! A bit of further reading (I've never done any php before...) and I'm done.

In summary, what we have here is;

1. Within a Article, the editor has the ability to type in key words, or "tags"... whatever they think is appropriate.

2. These Articles are then displayed in a grid format, usinging <li> and CSS.

3. Each <li> then has the "tags" applied as classes.

4. From the code in this thread, I'm now displaying all "tags" from all "articles", they are collated into like tags, and counted, then sorted in order or most popular (highest count). CSS and <li> forms the navigation.

5. Some jQuery magic then uses the navigation to filter the Article <li>'s via the "Tag" classes... and displays the filtered Articles List.

http://www.murraysbrewingco.com.au/web09/posts2.php

Thanks again!
Cheers,

Tim (toledoh.com.au)