Member
Member
Sabyre   29-08-2010, 05:23
#1

I'm trying to change functions-template so that when you view the archive and click on a date it returns ablums instead if images...

What do i need to change here?

`
/**

  • Retrieves a list of all unique years & months from the images in the gallery

  • @param string $order set to 'desc' for the list to be in descending order

  • @return array
    */
    function getAllDates($order='asc') {
    $alldates = array();
    $cleandates = array();
    $sql = "SELECT [code]date[/code] FROM ". prefix('albums');
    if (!zp_loggedin()) {
    $sql .= " WHERE [code]show[/code] = 1";
    }
    $hidealbums = getNotViewableAlbums();
    if (!is_null($hidealbums)) {
    if (zp_loggedin()) {
    $sql .= ' WHERE ';
    } else {
    $sql .= ' AND ';
    }
    foreach ($hidealbums as $id) {
    $sql .= '[code]albumid[/code]!='.$id.' AND ';
    }
    $sql = substr($sql, 0, -5);
    }
    $result = query_full_array($sql);
    foreach($result as $row){
    $alldates[] = $row['date'];
    }
    foreach ($alldates as $adate) {
    if (!empty($adate)) {
    $cleandates[] = substr($adate, 0, 7) . "-01";
    }
    }
    $datecount = array_count_values($cleandates);
    if ($order == 'desc') {
    krsort($datecount);
    } else {
    ksort($datecount);
    }
    return $datecount;
    }
    /**

  • Prints a compendum of dates and links to a search page that will show results of the date

  • @param string $class optional class

  • @param string $yearid optional class for "year"

  • @param string $monthid optional class for "month"

  • @param string $order set to 'desc' for the list to be in descending order
    */
    function printAllDates($class='archive', $yearid='year', $monthid='month', $order='asc') {
    global $_zp_current_search;
    if (!empty($class)){ $class = "class=\"$class\""; }
    if (!empty($yearid)){ $yearid = "class=\"$yearid\""; }
    if (!empty($monthid)){ $monthid = "class=\"$monthid\""; }
    $datecount = getAllDates($order);
    $lastyear = "";
    echo "\n\n";
    $nr = 0;
    while (list($key, $val) = each($datecount)) {
    $nr++;
    if ($key == '0000-00-01') {
    $year = "no date";
    $month = "";
    } else {
    $dt = strftime('%Y-%B', strtotime($key));
    $year = substr($dt, 0, 4);
    $month = substr($dt, 5);
    }

     if ($lastyear != $year) {
         $lastyear = $year;
         if($nr != 1) {  echo "\n\n";}
         echo "$year\n\n";
     }
     if (is_object($_zp_current_search)) {
         $albumlist = $_zp_current_search->album_list;
     } else {
         $albumlist = NULL;
     }
     echo "[*]$month ($val)\n";

    }
    echo "\n\n\n";
    }
    `

Member
Member
Sabyre   29-08-2010, 06:15
#2

I changed this...

echo "[*]$month ($val)\n"; }
To this...

echo "[*]$month ($val)\n"; }
And it seems to work.

It changed the URL from http://example.com/page/search/archive/DATE
to
http://example.com/page/search/DATE

Will this cause any issues with anything else?

Administrator
Administrator
acrylian   29-08-2010, 08:14
#3

You should never hack core files. Move that modified function to either the theme's functions.php (see the tutorial) and rename it or make a plugin with the renamed custom function. Otherwise you will most likely run into errors when upgrading.

Member
Member
Sabyre   30-08-2010, 02:03
#4

Excellent!

I created a functions.php and created a uniquely named function in it.

Thanks so much for that.

Now to remember how else I have changed the core files...

fun fun.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.