Hi Jan / All,
I saw in a post from you in 2015, that you wanted to enhance Phoca Gallery Search Plugin to be able to Search By Tags. Is this available? If not, is there some hack I can use to make this possible? If anyone can help me with what code to add in which file, I would be very grateful. My request is quite urgent, so I really appreciate if someone can help me implement this.
Thank you!
Namford
Ability to Search by Tags
-
- Phoca Member
- Posts: 22
- Joined: 25 Jun 2015, 18:11
- Jan
- Phoca Hero
- Posts: 48402
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Ability to Search by Tags
Hi, the search plugin searches for Phoca Gallery tags since version 4.0.4 so in version 4.2.2 (latest version) this should normaly work
Jan
Jan
If you find Phoca extensions useful, please support the project
-
- Phoca Member
- Posts: 22
- Joined: 25 Jun 2015, 18:11
Re: Ability to Search by Tags
Hi Jan, thanks for replying!
We had 4.0.4, so I just upgraded to 4.2.2 and still not working. Plugin is enabled and we are using smart search (it didn't work with normal search either when we had v4.0.4).
These are the 10 pictures i'm trying to return in the search:
http://phasmidstudygroup.org/index.php/ ... ?tagid=473
tag 473 is "Genus=Lamponius" and 10 photos are tagged with this.
But search returns only 9 photos, because it is searching inphoto name, not tag (and one photo does not have Lamponius in name):
http://phasmidstudygroup.org/index.php/ ... us&Search=
Please could you take a look? I can PM you login details if needed, but obviously won't post them here.
Thank you
We had 4.0.4, so I just upgraded to 4.2.2 and still not working. Plugin is enabled and we are using smart search (it didn't work with normal search either when we had v4.0.4).
These are the 10 pictures i'm trying to return in the search:
http://phasmidstudygroup.org/index.php/ ... ?tagid=473
tag 473 is "Genus=Lamponius" and 10 photos are tagged with this.
But search returns only 9 photos, because it is searching inphoto name, not tag (and one photo does not have Lamponius in name):
http://phasmidstudygroup.org/index.php/ ... us&Search=
Please could you take a look? I can PM you login details if needed, but obviously won't post them here.
Thank you
-
- Phoca Member
- Posts: 22
- Joined: 25 Jun 2015, 18:11
Re: Ability to Search by Tags
Jan, I'd like to work on fixing this this weekend - please could you reply on this? Thank you
- Jan
- Phoca Hero
- Posts: 48402
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Ability to Search by Tags
Hi, this was addes to standard search not smart search plugin.
switch ($phrase)
{
case 'exact':
$text = $db->quote('%'.$db->escape($text, true).'%', false);
$wheres2 = array();
$wheres2[] = 'a.title LIKE '.$text;
$wheres2[] = 'a.alias LIKE '.$text;
//$wheres2[] = 'a.name LIKE '.$text;
$wheres2[] = 'a.metakey LIKE '.$text;
$wheres2[] = 'a.metadesc LIKE '.$text;
$wheres2[] = 'a.description LIKE '.$text;
Are the tags Phoca Gallery tags?
Jan
switch ($phrase)
{
case 'exact':
$text = $db->quote('%'.$db->escape($text, true).'%', false);
$wheres2 = array();
$wheres2[] = 'a.title LIKE '.$text;
$wheres2[] = 'a.alias LIKE '.$text;
//$wheres2[] = 'a.name LIKE '.$text;
$wheres2[] = 'a.metakey LIKE '.$text;
$wheres2[] = 'a.metadesc LIKE '.$text;
$wheres2[] = 'a.description LIKE '.$text;
Code: Select all
$wheres2[] = 't.title LIKE '.$text;
$wheres2[] = 't.alias LIKE '.$text;
Jan
If you find Phoca extensions useful, please support the project
-
- Phoca Member
- Posts: 22
- Joined: 25 Jun 2015, 18:11
Re: Ability to Search by Tags
Thanks Jan. Yes, they are PG tags - you can see them displayed on the images here: http://phasmidstudygroup.org/index.php/ ... ?tagid=473
As mentioned, with v4.0.4, this feature was not working with standard search.
Which property in the code you posted is for the tag? I don't see one called 'tag'.
As mentioned, with v4.0.4, this feature was not working with standard search.
Which property in the code you posted is for the tag? I don't see one called 'tag'.
-
- Phoca Member
- Posts: 22
- Joined: 25 Jun 2015, 18:11
Re: Ability to Search by Tags
Jan / anyone,
I presume I need to add that extra search code to plugins/finder/phocagallery/phocagallery.php, but which function? I can't see a function that looks appropriate for this. Please help, I need to get this working ASAP.
Thank you
I presume I need to add that extra search code to plugins/finder/phocagallery/phocagallery.php, but which function? I can't see a function that looks appropriate for this. Please help, I need to get this working ASAP.
Thank you
-
- Phoca Member
- Posts: 22
- Joined: 25 Jun 2015, 18:11
Re: Ability to Search by Tags
I have modified this as follows - but what do I do next? Also, will this return multiple rows (since we have several tags per image)?
protected function getListQuery($query = null)
{
$db = JFactory::getDbo();
// Check if we can use the supplied SQL query.
$query = $query instanceof JDatabaseQuery ? $query : $db->getQuery(true)
->select('a.id, a.catid, a.title, a.alias, "" AS link, a.description AS summary')
->select('a.metakey, a.metadesc, a.metadata, a.language, a.ordering')
->select('"" AS created_by_alias, "" AS modified, "" AS modified_by')
//->select('"" AS publish_start_date, "" AS publish_end_date')
->select('a.published AS state, a.params, a.approved, 1 as access')
->select('c.title AS category, c.alias as categoryalias, c.published AS cat_state, c.access AS cat_access')
->select('t.title AS tag');
// Handle the alias CASE WHEN portion of the query
$case_when_item_alias = ' CASE WHEN ';
$case_when_item_alias .= $query->charLength('a.alias', '!=', '0');
$case_when_item_alias .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when_item_alias .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when_item_alias .= ' ELSE ';
$case_when_item_alias .= $a_id.' END as slug';
$query->select($case_when_item_alias);
$case_when_category_alias = ' CASE WHEN ';
$case_when_category_alias .= $query->charLength('c.alias', '!=', '0');
$case_when_category_alias .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when_category_alias .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when_category_alias .= ' ELSE ';
$case_when_category_alias .= $c_id.' END as catslug';
$query->select($case_when_category_alias)
->from('#__phocagallery AS a')
->join('LEFT', '#__phocagallery_categories AS c ON c.id = a.catid')
->join('LEFT', '#__phocagallery_tagsref AS r ON r.imgid = a.id')
->join('LEFT', '#__phocagallery_tags AS t ON t.id = r.tagid')
->where('a.approved = 1');
return $query;
}
protected function getListQuery($query = null)
{
$db = JFactory::getDbo();
// Check if we can use the supplied SQL query.
$query = $query instanceof JDatabaseQuery ? $query : $db->getQuery(true)
->select('a.id, a.catid, a.title, a.alias, "" AS link, a.description AS summary')
->select('a.metakey, a.metadesc, a.metadata, a.language, a.ordering')
->select('"" AS created_by_alias, "" AS modified, "" AS modified_by')
//->select('"" AS publish_start_date, "" AS publish_end_date')
->select('a.published AS state, a.params, a.approved, 1 as access')
->select('c.title AS category, c.alias as categoryalias, c.published AS cat_state, c.access AS cat_access')
->select('t.title AS tag');
// Handle the alias CASE WHEN portion of the query
$case_when_item_alias = ' CASE WHEN ';
$case_when_item_alias .= $query->charLength('a.alias', '!=', '0');
$case_when_item_alias .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when_item_alias .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when_item_alias .= ' ELSE ';
$case_when_item_alias .= $a_id.' END as slug';
$query->select($case_when_item_alias);
$case_when_category_alias = ' CASE WHEN ';
$case_when_category_alias .= $query->charLength('c.alias', '!=', '0');
$case_when_category_alias .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when_category_alias .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when_category_alias .= ' ELSE ';
$case_when_category_alias .= $c_id.' END as catslug';
$query->select($case_when_category_alias)
->from('#__phocagallery AS a')
->join('LEFT', '#__phocagallery_categories AS c ON c.id = a.catid')
->join('LEFT', '#__phocagallery_tagsref AS r ON r.imgid = a.id')
->join('LEFT', '#__phocagallery_tags AS t ON t.id = r.tagid')
->where('a.approved = 1');
return $query;
}
-
- Phoca Member
- Posts: 22
- Joined: 25 Jun 2015, 18:11
Re: Ability to Search by Tags
Jan, please can you help me?
- Jan
- Phoca Hero
- Posts: 48402
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Ability to Search by Tags
Hi, not sure if I didn't misunderstand.
I have talked about searching tags, not about displaying the in search outcome. Now the tags are searched - so if you add some tag from Phoca Gallery to search, the image will be found (but the tag is not displayed in search outcomes)
Not sure if the SQL will return tag, but in every case if it returns some, it will be only one (to get all, e.g. new query needs to be done, or contcat_ws or similar function needs to be used)
Where is the function getListQuery from?
I have talked about searching tags, not about displaying the in search outcome. Now the tags are searched - so if you add some tag from Phoca Gallery to search, the image will be found (but the tag is not displayed in search outcomes)
Not sure if the SQL will return tag, but in every case if it returns some, it will be only one (to get all, e.g. new query needs to be done, or contcat_ws or similar function needs to be used)
Where is the function getListQuery from?
If you find Phoca extensions useful, please support the project