forum.coppermine-gallery.net

Support => cpg1.3.x Support => Older/other versions => cpg1.3 Miscellaneous => Topic started by: Hein Traag on May 07, 2005, 06:31:57 pm

Title: Adding a url to album naming
Post by: Hein Traag on May 07, 2005, 06:31:57 pm
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
Title: Re: Adding a url to album naming
Post by: Nibbler on May 09, 2005, 01:37:21 am
Add the following after the require for init.inc.php in thumbnails.php

Code: [Select]
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
Title: Re: Adding a url to album naming
Post by: donnoman on May 09, 2005, 03:30:15 am
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):
Code: [Select]
$alb_list[$alb_idx]['album_title'] = $alb_thumb['title'];

replace with :
Code: [Select]
$alb_list[$alb_idx]['album_title'] = strip_tags(bb_decode($alb_thumb['title']));

thumbnails.php find;
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
$album_name = $album_name_keyword['title'];

replace with
Code: [Select]
$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:

Code: [Select]
[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.
Title: Re: Adding a url to album naming
Post by: Hein Traag on May 09, 2005, 06:41:08 pm
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
Title: Re: Adding a url to album naming
Post by: Hein Traag on May 09, 2005, 07:28:05 pm
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
Code: [Select]
[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
Code: [Select]
// 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
Title: Re: Adding a url to album naming
Post by: donnoman on May 09, 2005, 11:42:38 pm
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:
Code: [Select]
       foreach ($rowset as $row) {
            $select .= "<option value=\"" . $row["aid"] . "\">" . $row["title"] . "</option>\n";
        }

replace with:
Code: [Select]
       foreach ($rowset as $row) {
            $select .= "<option value=\"" . $row["aid"] . "\">" . strip_tags(bb_decode($row["title"] )). "</option>\n";
        }
Title: Re: Adding a url to album naming
Post by: Hein Traag on May 10, 2005, 07:30:29 pm
Found it. When using frogfoots mod for better sorting of the dropdown list you have to find this in searchnew.php

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

Code: [Select]
$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 
Code: [Select]
[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
Title: Re: Adding a url to album naming
Post by: Hein Traag on May 11, 2005, 05:11:02 pm
Code: [Select]
/**
 * 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 ?
Title: Re: Adding a url to album naming
Post by: donnoman on May 12, 2005, 08:13:04 pm
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.
Title: Re: Adding a url to album naming
Post by: Hein Traag on May 13, 2005, 03:57:47 pm
Donno i will try that out. Thanks for the tip.

Maybe, just maybe ;) i get to the end of my humble question LOL
Title: Re: Adding a url to album naming
Post by: Hein Traag on May 17, 2005, 08:16:17 pm
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.
Title: Re: Adding a url to album naming
Post by: donnoman on May 18, 2005, 06:01:03 pm
How about in that section of code find:
Code: [Select]
$album_array = array();
getallalbumsindb($album_array);

replace with:
Code: [Select]
$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.
Title: Re: Adding a url to album naming
Post by: Hein Traag on May 20, 2005, 05:00:29 pm
Just one page involved. Searchnew.php is the only one as far as i can see.