Keyword

Is it possible to mass add a tag in all items of one category?!

  • B_Dark
  • B_Dark's Avatar Topic Author
  • Offline
  • Premium Member
More
13 years 10 months ago #97132 by B_Dark
i believe only with sql command is the solution. i search in my sql database but i don't know how to do. any help plz?!

Please Log in or Create an account to join the conversation.

More
13 years 10 months ago #97133 by Andrea Vigato
In jos_k2_tags_xref you have the reference between a tag and a item.

 

just a query with your id of the mass tag (tagID column) related to the itemID (the post)...

Please Log in or Create an account to join the conversation.

  • B_Dark
  • B_Dark's Avatar Topic Author
  • Offline
  • Premium Member
More
13 years 10 months ago #97134 by B_Dark
and if you want all the items of one category with a specific tag?

Andrea Vigato said:
In jos_k2_tags_xref you have the reference between a tag and a item.

 

just a query with your id of the mass tag (tagID column) related to the itemID (the post)...

Please Log in or Create an account to join the conversation.

More
13 years 10 months ago #97135 by Andrea Vigato
so do the query when the user add an item in a certain category....

 

first check the category id, if it's the category you want do the query to set a specific tagID to the item the user it's creating...i think you must use form.php in com_k2/views/tmpl, don't remember now...


B_Dark said:

and if you want all the items of one category with a specific tag?
Andrea Vigato said:
In jos_k2_tags_xref you have the reference between a tag and a item.

 

just a query with your id of the mass tag (tagID column) related to the itemID (the post)...

Please Log in or Create an account to join the conversation.

  • B_Dark
  • B_Dark's Avatar Topic Author
  • Offline
  • Premium Member
More
13 years 10 months ago #97136 by B_Dark
a specific tag in all items of a specific category. like tag "Trailer" in all items of category "Cinema"

B_Dark said:
and if you want all the items of one category with a specific tag?
Andrea Vigato said:
In jos_k2_tags_xref you have the reference between a tag and a item.

 

just a query with your id of the mass tag (tagID column) related to the itemID (the post)...

Please Log in or Create an account to join the conversation.

More
13 years 10 months ago #97137 by Andrea Vigato
yes, as i said...right before user is adding a new item you have to check the cat id he choosed, if it's "Cinema" category add the query to set the tagID to the item...

Please Log in or Create an account to join the conversation.

  • B_Dark
  • B_Dark's Avatar Topic Author
  • Offline
  • Premium Member
More
13 years 10 months ago #97138 by B_Dark
wait in table  jos_k2_tags_xref  have 2 columns: tagID(tagID column)itemID(the post)so how i put in 600 items of category "Cinema" the tag "Trailer" with 1-2 steps and not one by one?

Andrea Vigato said:
yes, as i said...right before user is adding a new item you have to check the cat id he choosed, if it's "Cinema" category add the query to set the tagID to the item...

Please Log in or Create an account to join the conversation.

More
13 years 10 months ago #97139 by Andrea Vigato
you have to do it for future items or for 600 items present right now in the category cinema?

 

If it's for the future do the query when the user add item, if it's for now you will have to do a query and activate it from the site (just for this and then delete everything)...you will have to check where the itemID is related (to a catID) and if it's ok change the tagID. Not so difficult don't worry...

Please Log in or Create an account to join the conversation.

  • B_Dark
  • B_Dark's Avatar Topic Author
  • Offline
  • Premium Member
More
13 years 10 months ago #97140 by B_Dark
for 600 items present right now in the category cinema

Andrea Vigato said:

you have to do it for future items or for 600 items present right now in the category cinema?

 

If it's for the future do the query when the user add item, if it's for now you will have to do a query and activate it from the site (just for this and then delete everything)...you will have to check where the itemID is related (to a catID) and if it's ok change the tagID. Not so difficult don't worry...

Please Log in or Create an account to join the conversation.

More
13 years 10 months ago #97141 by Andrea Vigato
because what i know of K2 tag system is that the tag is related to the item, not the category.

 

tagID -> itemID -> catID

 

So you cannot just add a tag ID to the category, you have to check the category you want if it's related to the item then add a reference of the tag you want...maybe after work i'll write you some code ok?
B_Dark said:

ok the one column tagID is the one of column part order to find the solution, the other one column itemID is for one specific item id, right? so, i don't understood how with itemID i have a solution for mass add tag "trailer" in 600 item that i have save in my category "cinema'?! sorry if i make rowng but really i don't understood how this column (itemID) is my solution
Andrea Vigato said:
no, 

 

id (id related to the entry of the jos_k2_tags_xref) 

tagID (id of the related Tag)

itemID (id of the related Item)

 

you have to use tagID and itemID, id it's not important for your question....

Please Log in or Create an account to join the conversation.

  • B_Dark
  • B_Dark's Avatar Topic Author
  • Offline
  • Premium Member
More
13 years 10 months ago #97142 by B_Dark
so we can't add a specifc tag in all items of present right now in a spesific category?
Andrea Vigato said:
because what i know of K2 tag system is that the tag is related to the item, not the category.

 

tagID -> itemID -> catID

 

So you cannot just add a tag ID to the category, you have to check the category you want if it's related to the item then add a reference of the tag you want...maybe after work i'll write you some code ok? B_Dark said:

ok the one column tagID is the one of column part order to find the solution, the other one column itemID is for one specific item id, right? so, i don't understood how with itemID i have a solution for mass add tag "trailer" in 600 item that i have save in my category "cinema'?! sorry if i make rowng but really i don't understood how this column (itemID) is my solution Andrea Vigato said:
no, 

 

id (id related to the entry of the jos_k2_tags_xref) 

tagID (id of the related Tag)

itemID (id of the related Item)

 

you have to use tagID and itemID, id it's not important for your question....

Please Log in or Create an account to join the conversation.

More
13 years 10 months ago #97143 by Andrea Vigato
yes you can, but not in an easy way :) you have to create a SQL query and modify the DB.

 

Something like:

SELECT itemID FROM jos_K2_item WHERE catid = (the id of your category)

and then an UPDATE in those itemID to set tagID = your tag ID.

 

 


B_Dark said:

so we can't add a specifc tag in all items of present right now in a spesific category?
Andrea Vigato said:
because what i know of K2 tag system is that the tag is related to the item, not the category.

 

tagID -> itemID -> catID

 

So you cannot just add a tag ID to the category, you have to check the category you want if it's related to the item then add a reference of the tag you want...maybe after work i'll write you some code ok? B_Dark said:

ok the one column tagID is the one of column part order to find the solution, the other one column itemID is for one specific item id, right? so, i don't understood how with itemID i have a solution for mass add tag "trailer" in 600 item that i have save in my category "cinema'?! sorry if i make rowng but really i don't understood how this column (itemID) is my solution Andrea Vigato said:no, 

 

id (id related to the entry of the jos_k2_tags_xref) 

tagID (id of the related Tag)

itemID (id of the related Item)

 

you have to use tagID and itemID, id it's not important for your question....

Please Log in or Create an account to join the conversation.

  • B_Dark
  • B_Dark's Avatar Topic Author
  • Offline
  • Premium Member
More
13 years 10 months ago #97144 by B_Dark
Is it possible with this SQL query to erase the other tags of any item of this category ?!

Andrea Vigato said:
yes you can, but not in an easy way :) you have to create a SQL query and modify the DB.

 

Something like:

SELECT itemID FROM jos_K2_item WHERE catid = (the id of your category)

and then an UPDATE in those itemID to set tagID = your tag ID.

 

 

B_Dark said:

so we can't add a specifc tag in all items of present right now in a spesific category? Andrea Vigato said:
because what i know of K2 tag system is that the tag is related to the item, not the category.

 

tagID -> itemID -> catID

 

So you cannot just add a tag ID to the category, you have to check the category you want if it's related to the item then add a reference of the tag you want...maybe after work i'll write you some code ok? B_Dark said:

ok the one column tagID is the one of column part order to find the solution, the other one column itemID is for one specific item id, right? so, i don't understood how with itemID i have a solution for mass add tag "trailer" in 600 item that i have save in my category "cinema'?! sorry if i make rowng but really i don't understood how this column (itemID) is my solution Andrea Vigato said:no, 

 

id (id related to the entry of the jos_k2_tags_xref) 

tagID (id of the related Tag)

itemID (id of the related Item)

 

you have to use tagID and itemID, id it's not important for your question....

Please Log in or Create an account to join the conversation.

  • B_Dark
  • B_Dark's Avatar Topic Author
  • Offline
  • Premium Member
More
13 years 10 months ago #97145 by B_Dark
beacose i dont want to erese the other tagid's of any item of this category i want only to add another one tag only to this items of this category

B_Dark said:
Is it possible with this SQL query to erase the other tags of any item of this category ?!
Andrea Vigato said:
yes you can, but not in an easy way :) you have to create a SQL query and modify the DB.

 

Something like:

SELECT itemID FROM jos_K2_item WHERE catid = (the id of your category)

and then an UPDATE in those itemID to set tagID = your tag ID.

 

 

B_Dark said:

so we can't add a specifc tag in all items of present right now in a spesific category? Andrea Vigato said:because what i know of K2 tag system is that the tag is related to the item, not the category.

 

tagID -> itemID -> catID

 

So you cannot just add a tag ID to the category, you have to check the category you want if it's related to the item then add a reference of the tag you want...maybe after work i'll write you some code ok? B_Dark said:

ok the one column tagID is the one of column part order to find the solution, the other one column itemID is for one specific item id, right? so, i don't understood how with itemID i have a solution for mass add tag "trailer" in 600 item that i have save in my category "cinema'?! sorry if i make rowng but really i don't understood how this column (itemID) is my solution Andrea Vigato said:no, 

 

id (id related to the entry of the jos_k2_tags_xref) 

tagID (id of the related Tag)

itemID (id of the related Item)

 

you have to use tagID and itemID, id it's not important for your question....

Please Log in or Create an account to join the conversation.

More
13 years 10 months ago #97146 by Andrea Vigato
i'm out of home now, anyway..if you have to update with no erase you will have to save a new field, as i see in the sql any item id that got more than one tag got a reference to more tagID.

 

So what you just need to do is: 

 

(First Query)

SELECT itemID FROM jos_k2_items

WHERE catid = $catid

 

$catID = the ID of your category "Cinema"

 

(Second Query)

INSERT INTO jos_k2_tag_xref

VALUES ($id, $tagID, $itemID)

 

$id: must to be a incremental number from the last id in jos_k2_tag_xref to counter of the first query, or just an incremental number if you want.

 

$tagID: is the ID of the tag you want to add, like 8 don't know.

 

$itemID: with the first query you have saved an array of the itemID you must change. Use it to dinamic change this var.

 

Some link to use jdb if you need:

api.joomla.org/Joomla-Framework/Database/JDatabase.html

docs.joomla.org/How_to_use_the_database_classes_in_your_script

 

Hope will be ok :) sorry if it's a bit confusion...
B_Dark said:

beacose i dont want to erese the other tagid's of any item of this category i want only to add another one tag only to this items of this category
B_Dark said:
Is it possible with this SQL query to erase the other tags of any item of this category ?! Andrea Vigato said:
yes you can, but not in an easy way :) you have to create a SQL query and modify the DB.

 

Something like:

SELECT itemID FROM jos_K2_item WHERE catid = (the id of your category)

and then an UPDATE in those itemID to set tagID = your tag ID.

 

 

B_Dark said:

so we can't add a specifc tag in all items of present right now in a spesific category? Andrea Vigato said:because what i know of K2 tag system is that the tag is related to the item, not the category.

 

tagID -> itemID -> catID

 

So you cannot just add a tag ID to the category, you have to check the category you want if it's related to the item then add a reference of the tag you want...maybe after work i'll write you some code ok? B_Dark said:

ok the one column tagID is the one of column part order to find the solution, the other one column itemID is for one specific item id, right? so, i don't understood how with itemID i have a solution for mass add tag "trailer" in 600 item that i have save in my category "cinema'?! sorry if i make rowng but really i don't understood how this column (itemID) is my solution Andrea Vigato said:no, 

 

id (id related to the entry of the jos_k2_tags_xref) 

tagID (id of the related Tag)

itemID (id of the related Item)

 

you have to use tagID and itemID, id it's not important for your question....

Please Log in or Create an account to join the conversation.

  • B_Dark
  • B_Dark's Avatar Topic Author
  • Offline
  • Premium Member
More
13 years 10 months ago #97147 by B_Dark
SELECT itemID FROM jos_k2_items

WHERE catid = 8INSERT INTO jos_k2_tag_xref

VALUES (4356, 12, itemID)

something like this?

Andrea Vigato said:
i'm out of home now, anyway..if you have to update with no erase you will have to save a new field, as i see in the sql any item id that got more than one tag got a reference to more tagID.

 

So what you just need to do is: 

 

(First Query)

SELECT itemID FROM jos_k2_items

WHERE catid = $catid

 

$catID = the ID of your category "Cinema"

 

(Second Query)

INSERT INTO jos_k2_tag_xref

VALUES ($id, $tagID, $itemID)

 

$id: must to be a incremental number from the last id in jos_k2_tag_xref to counter of the first query, or just an incremental number if you want.

 

$tagID: is the ID of the tag you want to add, like 8 don't know.

 

$itemID: with the first query you have saved an array of the itemID you must change. Use it to dinamic change this var.

 

Some link to use jdb if you need:

api.joomla.org/Joomla-Framework/Database/JDatabase.html

docs.joomla.org/How_to_use_the_database_classes_in_your_script

 

Hope will be ok :) sorry if it's a bit confusion... B_Dark said:

beacose i dont want to erese the other tagid's of any item of this category i want only to add another one tag only to this items of this category B_Dark said:
Is it possible with this SQL query to erase the other tags of any item of this category ?! Andrea Vigato said:yes you can, but not in an easy way :) you have to create a SQL query and modify the DB.

 

Something like:

SELECT itemID FROM jos_K2_item WHERE catid = (the id of your category)

and then an UPDATE in those itemID to set tagID = your tag ID.

 

 

B_Dark said:

so we can't add a specifc tag in all items of present right now in a spesific category? Andrea Vigato said:because what i know of K2 tag system is that the tag is related to the item, not the category.

 

tagID -> itemID -> catID

 

So you cannot just add a tag ID to the category, you have to check the category you want if it's related to the item then add a reference of the tag you want...maybe after work i'll write you some code ok? B_Dark said:

ok the one column tagID is the one of column part order to find the solution, the other one column itemID is for one specific item id, right? so, i don't understood how with itemID i have a solution for mass add tag "trailer" in 600 item that i have save in my category "cinema'?! sorry if i make rowng but really i don't understood how this column (itemID) is my solution Andrea Vigato said:no, 

 

id (id related to the entry of the jos_k2_tags_xref) 

tagID (id of the related Tag)

itemID (id of the related Item)

 

you have to use tagID and itemID, id it's not important for your question....

Please Log in or Create an account to join the conversation.

More
13 years 10 months ago #97148 by Andrea Vigato
yes, do a backup first :)

 

SELECT is the first query where you save an array of itemID.

After that you use the INSERT INTO query to set the values in the itemID passed from the array.

 

remember that 4356 must be an incremental value and itemID must be the value passed from the array of the first query.


B_Dark said:

SELECT itemID FROM jos_k2_items

WHERE catid = 8INSERT INTO jos_k2_tag_xref

VALUES (4356, 12, itemID)

something like this?

Andrea Vigato said:
i'm out of home now, anyway..if you have to update with no erase you will have to save a new field, as i see in the sql any item id that got more than one tag got a reference to more tagID.

 

So what you just need to do is: 

 

(First Query)

SELECT itemID FROM jos_k2_items

WHERE catid = $catid

 

$catID = the ID of your category "Cinema"

 

(Second Query)

INSERT INTO jos_k2_tag_xref

VALUES ($id, $tagID, $itemID)

 

$id: must to be a incremental number from the last id in jos_k2_tag_xref to counter of the first query, or just an incremental number if you want.

 

$tagID: is the ID of the tag you want to add, like 8 don't know.

 

$itemID: with the first query you have saved an array of the itemID you must change. Use it to dinamic change this var.

 

Some link to use jdb if you need:

api.joomla.org/Joomla-Framework/Database/JDatabase.html

docs.joomla.org/How_to_use_the_database_classes_in_your_script

 

Hope will be ok :) sorry if it's a bit confusion... B_Dark said:

beacose i dont want to erese the other tagid's of any item of this category i want only to add another one tag only to this items of this category B_Dark said:Is it possible with this SQL query to erase the other tags of any item of this category ?! Andrea Vigato said:yes you can, but not in an easy way :) you have to create a SQL query and modify the DB.

 

Something like:

SELECT itemID FROM jos_K2_item WHERE catid = (the id of your category)

and then an UPDATE in those itemID to set tagID = your tag ID.

 

 

B_Dark said:

so we can't add a specifc tag in all items of present right now in a spesific category? Andrea Vigato said:because what i know of K2 tag system is that the tag is related to the item, not the category.

 

tagID -> itemID -> catID

 

So you cannot just add a tag ID to the category, you have to check the category you want if it's related to the item then add a reference of the tag you want...maybe after work i'll write you some code ok? B_Dark said:

ok the one column tagID is the one of column part order to find the solution, the other one column itemID is for one specific item id, right? so, i don't understood how with itemID i have a solution for mass add tag "trailer" in 600 item that i have save in my category "cinema'?! sorry if i make rowng but really i don't understood how this column (itemID) is my solution Andrea Vigato said:no, 

 

id (id related to the entry of the jos_k2_tags_xref) 

tagID (id of the related Tag)

itemID (id of the related Item)

 

you have to use tagID and itemID, id it's not important for your question....

Please Log in or Create an account to join the conversation.

  • B_Dark
  • B_Dark's Avatar Topic Author
  • Offline
  • Premium Member
More
13 years 10 months ago #97149 by B_Dark
ok i use the first query the right is "id" from this table, i tell this if someone else want to do the sameSELECT IDFROM jos_k2_itemsWHERE catid =8[/code]the give me 18 pages with the id's of the items of category "cinema" (8)after? how i give the values of itemid's from first in sec query?

Please Log in or Create an account to join the conversation.

  • B_Dark
  • B_Dark's Avatar Topic Author
  • Offline
  • Premium Member
More
13 years 10 months ago #97150 by B_Dark
the right sec teble name is jos_k2_tags_xref#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO jos_k2_tags_xref VALUES (44, 40, itemID) LIMIT 0, 30' at line 6
SELECT IDFROM jos_k2_itemsWHERE catid =33INSERT INTO jos_k2_tags_xrefVALUES ( [/code]44, 40, itemID ) LIMIT 0 , 30they give me this message, what i write wrong?[/code]

Please Log in or Create an account to join the conversation.

More
13 years 10 months ago #97151 by Andrea Vigato
Ok,

/******************************************************/

 


// $db =& JFactory::getDBO();
// $first_query = "SELECT ID FROM jos_k2_items WHERE catid=8";
// $db->setQuery($first_query);


// $counter = $db->getNumRows(); // we get the number of rows created, cycle value
// $column= $db->loadResultArray(); // load all the result in a var, then access the values with the index of the for


// $start_id = 44; // or the last ID value in the jos_k2_tags_xref

// for($i=0; $i<=$counter; $i++) {



// $second_query = "INSERT INTO jos_k2_tags_xref VALUES ($start_id, 40, $column[$i])";

// $db->setQuery($second_query);


// $start_id++;


// }[/code]
[/code]

/********************************/[/code][/code]


the INSERT INTO query not have the SELECT FROM WHERE.

I think it's ok, maybe check it for some operators error...

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum