Adding a url to album naming Adding a url to album naming
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Adding a url to album naming

Started by Hein Traag, May 07, 2005, 06:31:57 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Hein Traag

G'day all and thanks for opening this wee little thread ;)

I have a new CM in the making and i have stumbled upon a question which i can not solve with my little knowledge of PHP.

I would very much like to add a clickable url where the name of album is mentioned.

The new CM that i am setting up hosts pictures taken at events that are held by scouting in the Netherlands. The idea is to give groups who attended such a camp or event a place to host part of their pictures that they have taken and add a link to there own galleries with more pictures. Only thing is i can't figure out how to add a new Album and have a clickable url in the album naming.

Maybe someone can share his knowledge with me and others.

Thanks!
Hein

Nibbler

Add the following after the require for init.inc.php in thumbnails.php

if (isset($_GET['albname'])){
$album = addslashes($_GET['albname']);
$query = db_query("SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE title = '$album' LIMIT 1");
if ($query) list($_GET['album']) = mysql_fetch_row($query);
}


It's basic but should work ok, call the album using thumbnails.php?albname=whatever

donnoman

I think maybe he was thinking on the order of being able to use bbcode for an album name, that way the album name itself could be a clickable link to an offsite url.

index.php find (four times):

$alb_list[$alb_idx]['album_title'] = $alb_thumb['title'];


replace with :

$alb_list[$alb_idx]['album_title'] = strip_tags(bb_decode($alb_thumb['title']));


thumbnails.php find;

if (is_numeric($album)) {
   $result = db_query("SELECT category, title, aid, keyword, description FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid='$album'");
   if (mysql_num_rows($result) > 0) {
       $CURRENT_ALBUM_DATA = mysql_fetch_array($result);
       $actual_cat = $CURRENT_ALBUM_DATA['category'];
       $CURRENT_ALBUM_KEYWORD = $CURRENT_ALBUM_DATA['keyword'];


replace with:

if (is_numeric($album)) {
   $result = db_query("SELECT category, title, aid, keyword, description FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid='$album'");
   if (mysql_num_rows($result) > 0) {
       $CURRENT_ALBUM_DATA = mysql_fetch_array($result);
       $actual_cat = $CURRENT_ALBUM_DATA['category'];
       $CURRENT_ALBUM_KEYWORD = $CURRENT_ALBUM_DATA['keyword'];
       $CURRENT_ALBUM_DATA['title']=strip_tags(bb_decode($CURRENT_ALBUM_DATA['title']));


in functions.inc.php function get_pic_data find:

$album_name = $album_name_keyword['title'];


replace with

$album_name = '<span class="statlink">'.bb_decode($album_name_keyword['title']).'</span>';


Then to take advantage of it, change the album title to something like this:


[url=http://blueoxhardwoodflooring.com]Blue Ox[/url]


There may be other areas where it makes sense to clean up the album name but this gives you the basic functionality.

Hein Traag

#3
Donnoman's solution sounds like what i am looking for. Will have a go at implementing this.
Nibbler thanks for the support anyhow ;)

brb

Back again. It works as Donnoman suggested. Works as i imagined it. Thanks Donnoman and Nibbler for the input.

I figure this is not something that might be worth adding as an extra to the new CPG ? Does not do anybody any harm and is a nice little extra feature imho.

Thanks!
Hein

Hein Traag

#4
Well it works alright ;) but i have one little thing to clean up. As Donnoman says there might be places to clean up the album name. That place is somewhere in searchnew.php because when use the dropdown list is displays the album names as [url=http://www.something.com]Album name[/url].

Is there a way to modify searchnew.php so it does not read bb code in album naming ? There probably is :) would be great if someone knew where.

I did modify my searchnew.php with frogfoots mod already to have a better sorting. But even then I think it's enough to edit this line
// Sort the pulldown options by category and album name
        $listArray = array_csort($listArray,'cat','title');


Sometimes i wish for a php coding addon for the human brain  :-\\

Thanks again!
Hein

donnoman

I'm not sure about after the addition of frogfoots, but you need to find the array that holds the title and then run

bb_decode on it which transforms it to real html
then run a strip_tags on it which removes all html tags from it, in order to clean it up.

in regular 1.3.3 without frogfoots find function albumselect:

       foreach ($rowset as $row) {
           $select .= "<option value=\"" . $row["aid"] . "\">" . $row["title"] . "</option>\n";
       }


replace with:

       foreach ($rowset as $row) {
           $select .= "<option value=\"" . $row["aid"] . "\">" . strip_tags(bb_decode($row["title"] )). "</option>\n";
       }

Hein Traag

#6
Found it. When using frogfoots mod for better sorting of the dropdown list you have to find this in searchnew.php

$select .= '<option value="' . $val[aid] . '"' . ($val[aid] == $sel_album ? ' selected' : '') . '>   ' . $val[title] . "</option>\n";

And replace with

$select .= '<option value="' . $val[aid] . '"' . ($val[aid] == $sel_album ? ' selected' : '') . '>   ' . strip_tags(bb_decode($val["title"] )) . "</option>\n";

And moving on. When tackled this one the next one shows up :). When you select the album you need the pics to be inserted in you get the page where it displays the  folder name/image name/ album name. At that point it does that  [url=http://http//]URL[/url] again.  Going to look for it, trial and error, but if you feel like helping out don't hesitate  ;D

Hein Traag

#7

/**
* Main code
*/

$album_array = array();
getallalbumsindb($album_array);
// We need at least one album
if (!count($album_array)) cpg_die(ERROR, $lang_search_new_php['need_one_album'], __FILE__, __LINE__);

if (isset($HTTP_POST_VARS['insert'])) {
    if (!isset($HTTP_POST_VARS['pics'])) cpg_die(ERROR, $lang_search_new_php['no_pic_to_add'], __FILE__, __LINE__);

    pageheader($lang_search_new_php['page_title']);
    starttable("100%");
    echo <<<EOT
        <tr>
                <td colspan="4" class="tableh1"><h2>{$lang_search_new_php['insert']}</h2></td>
        </tr>
        <tr>
                <td class="tableh2" valign="middle" align="center"><b>{$lang_search_new_php['folder']}</b></td>
                <td class="tableh2" valign="middle" align="center"><b>{$lang_search_new_php['image']}</b></td>
                <td class="tableh2" valign="middle" align="center"><b>{$lang_search_new_php['album']}</b></td>
                <td class="tableh2" valign="middle" align="center"><b>{$lang_search_new_php['result']}</b></td>
        </tr>
EOT;


Right, this is i think the table section i need to modify to have the album name correctly displayed, i.e. without the bbcode. I tried my best but can't seem to duplicate the result i got with the dropdown list album naming. I the above section what i need to edit or is it not ?

donnoman

Hein, I would go deeper into getallalbumsindb($album_array);

and do the replacement in there.

That section of code really just prints the word "Album" from the language files, not the actual album name.

Hein Traag

Donno i will try that out. Thanks for the tip.

Maybe, just maybe ;) i get to the end of my humble question LOL

Hein Traag

Well may the maker be my witness i can't figure it out. Keep getting a blank page everytime i try a modification somewhere in that array which handles the album naming. Anybody got some other pointers ? :) i do appreciate the help guys and gals.

donnoman

How about in that section of code find:

$album_array = array();
getallalbumsindb($album_array);


replace with:

$album_array = array();
getallalbumsindb($album_array);
foreach ($album_array as $key => $item) {
     $album_array[$key][title]=strip_tags(bb_decode($item['title'] ));
}


If that doesn't work why don't you zip up the pages involved and attach them to this thread and I'll take a look at them.

Hein Traag

Just one page involved. Searchnew.php is the only one as far as i can see.