![]() |
|
unique tag skips search page and goes straight to image or album page - Printable Version +- ZenphotoCMS Forum (https://forum.zenphoto.org) +-- Forum: Support (https://forum.zenphoto.org/forum-1.html) +--- Forum: General support (https://forum.zenphoto.org/forum-4.html) +--- Thread: unique tag skips search page and goes straight to image or album page (/thread-2166.html) |
unique tag skips search page and goes straight to image or album page - BertSimons - 2008-01-29 I have some 'unique' tags, e.g there is only one instance of such a tag. I kind of hustled together something that works for albums with a 'unique' tag. in the function printAlltagsAs() I added an if condition for the '$val', so if a tag occures only once a different link is printed, one straight to the album or image; ` if ($val==1){
}else{
} ` this works well for albums with only one unique tag, you can see it at www.bertsimons.nl e.g the tags 18+ or wishlist take you straight to these albums any suggestions? unique tag skips search page and goes straight to image or album page - sbillard - 2008-01-30 The SQL is almost identical, just substitute "images" for "albums". So, your code would look something like: `if ($val==1){ $sql="SELECT * FROM ". prefix("albums") ." WHERE tags LIKE '%".$key."%'"; $album = mysql_query($sql); if ($album) { $a = mysql_fetch_array($album); $path=rewrite_path("/index.php?album=" . urlencode($a[2])); echo "t".$key."n"; } else { $sql="SELECT * FROM ". prefix("images") ." WHERE tags LIKE '%".$key."%'"; $image = mysql_query($sql); } }else{ $key = str_replace('"', '', $key); echo "t". $key.$counter."n"; }` unique tag skips search page and goes straight to image or album page - BertSimons - 2008-01-30 pff took me another hour.. your :-) but is is working.. see the tag unique on my site.. code used to get the image link was this `{ $sql="SELECT * FROM ". prefix("images") ." WHERE tags LIKE '%".$key."%'"; $image = mysql_query($sql); $i = mysql_fetch_array($image); $albumid = $i[1]; $image = $i[2]; $sql = "SELECT * FROM ". prefix("albums") ." WHERE id LIKE '%".$albumid."%'"; $album = mysql_query($sql); $album = mysql_fetch_array($album); $album = $album[2]; $path=rewrite_path("/index.php?album=" . $album ."&image=".$image); echo "t".$key."n"; }` thanks! unique tag skips search page and goes straight to image or album page - sbillard - 2008-01-30 What happens if the image is password protected or invisible? If that all works this might be a good feature option to add to the core. unique tag skips search page and goes straight to image or album page - acrylian - 2008-01-30 Protected albums and not published images probably won't work with these queries. Both queries would need a "AND show = 1" (show in backticks of course!). And the checkAlbumPassword()-loop we use in the rss would need to be included in the second query, too, I guess. BertSimons: I also suggest that you use the db functions we have, would save you a few lines of code...:-) unique tag skips search page and goes straight to image or album page - BertSimons - 2008-01-30 unique tags from invisible albums or image didn't shoiw up in the taglist. uniique tags from password protected albums showed up but pointed to the password form so that's ok too. however unique tagged images in password protected albums did show up. so had to add something. code is now
if ($val==1){
$a = mysql_fetch_array($album); if (!empty($a)) { $path=rewrite_path("/index.php?album=" . urlencode($a[2]));
}else{ $sql="SELECT * FROM ". prefix("images") ." WHERE tags LIKE '%".$key."%'"; $image = mysql_query($sql); $i = mysql_fetch_array($image); $albumidimage = $i[1]; $image = $i[2]; $sql = "SELECT * FROM ". prefix("albums") ." WHERE id LIKE '%".$albumidimage."%'"; $album = mysql_query($sql); $album = mysql_fetch_array($album); $albumpath = $album[2]; $passwordcheck=$album[18]; if (empty($passwordcheck)){ $path=rewrite_path("/index.php?album=" . $albumpath ."&image=".$image);
} } }else{
}
} // while end echo "n"; }` so it works with me here, second opinion testing required off course. I guess getting the fields from the query table with $album[18] etc is not so nice when table fields are going to be added and the nuber changes unique tag skips search page and goes straight to image or album page - acrylian - 2008-01-30 I haven't tested you code. But please note that the password field in the albums table only protects that album, not the sub albums of that album. We have a function for this called You could take a look at the rss feed of the nightly where this is used. unique tag skips search page and goes straight to image or album page - BertSimons - 2008-01-30 yes you are right..code only checks to see if album in which unique tagged image is found is password protected and not checks wheter it's album's parentalbum(s) is protected.. unique tag skips search page and goes straight to image or album page - sbillard - 2008-01-30 I think the main problem is that something with a "unique" tag in the search may not actually be unique if there is another image/album that has the tag but is protected/invisible. Somehow what is needed is to use the zenphoto search again for the unique tag. unique tag skips search page and goes straight to image or album page - BertSimons - 2008-01-30 I am very busy right now with a not behind my pc deadline project so can't look into that right away but this weekend ill do some math.. perhaps it's to do like this $val now is calculated by getAlltags which is defined in the templates function only to select those WHERE show = 1 so a new function getAllTagsEvenThoseWhoAreHidden() could return the number of a certain tag including hidden and protected images. unique tag skips search page and goes straight to image or album page - sbillard - 2008-01-31 I was thinking more on the lines: `if ($val=1) { $search = new SearchEngine(); $search->words = $uniqueTag; $search->fields = SEARCH_TAG; $search->dates = ''; $uniqueAlbum = $search->getAlbums(); if (count($uniqueAlbum) > 0) { } else { $uniqueImage = $search->getSearchImages(); if (count($uniqueImage) > 0) { } else { }` This way the search engine will be using the same queries/password protection as the tag query. Of course the stuff within the `` is left to the 'student' as the professor likes to say. unique tag skips search page and goes straight to image or album page - BertSimons - 2008-02-03 basically got it working. before printing the unique tag link i checked in a while loop if one of the unique tagged image's or album's parent albums is flagged as protected or invisible and if so not to print it's link. ` ................... echo "t".$key.$counter."n"; } else { if ($val==1){ $sql="SELECT * FROM ". prefix("albums") ." WHERE tags LIKE '%".$key."%'"; $album = mysql_query($sql); $album = mysql_fetch_array($album); $parentid = $album[1]; $path=rewrite_path("/index.php?album=" . urlencode($album[2])); if (!empty($album)) { $check=0; while (!empty($parentid)) { $sql = "SELECT * FROM ". prefix("albums") ." WHERE id LIKE '%".$parentid."%'"; $album = mysql_query($sql); $album = mysql_fetch_array($album); $parentid = $album[1]; if ($album[7] == 0){$check=$check+1;} if (!empty($album[18])){$check=$check+1;} } if ($check |