Jump to content

Best way to implement Tag system


Harmster
 Share

Recommended Posts

Hey, 

I am, for my final project on school, making a picture database. The client wants to search in the database and I figured I implement a tag system. 

What is the best way to implement a tag system? 

A repeater field, a string field or an asm select ish input field?

Thanks

Link to comment
Share on other sites

Yes, simply use a page field in conjunction with ASM and autocomplete (er, I think) and set up parent and child templates for the actual tags - so each tag is a page.

If you set the page field to allow the creation of pages, and make sure your parent template can only use one template for children, then as you type it will autosearch for existing tags and if none exist then it will create one on return.

Link to comment
Share on other sites

Thanks for all your tips, for anyone also looking for a solution int he future ill describe what I did:

I created a wrapper called tags and a new template tag.

In the template I made 2 fields, title and page (A single page array)

Then I created a searchbox and the following code:

if($input->post->submit){
   //form has been submitted;
   $tag = str_replace(',','|', $input->post->tag_search);
   $results = $pages->find("template=tag, tag=$tag");
}

This is for searching on multiple tags.. 

This works like a charm and it is very, very flexible!

Thanks everyone for your time & help!

  • Like 3
Link to comment
Share on other sites

Depending on the amount of tags involved, you might want to use a "limit" in your selector. Hey, this is a school project so might as well show them best practise... :P  ^_^

Yeah, thats probably a good practise, though I just started to implement this, I think I want to implement infinite scrolling too :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...