actuel Albums actuel Albums
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

actuel Albums

Started by Crazymodder, January 03, 2009, 12:14:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Crazymodder

Hello everybody.
At first I wish all the readers a happy new year.
I plan a little mod because i don't find anything. So if there is Monday I want to generate automaticly a link to an album. This link should be shown in over the admin menü. So which file i have to edit the themes.inc.php or my theme.php.
The actuell code looks so:

$timestamp = time();
$datum = date("d.m.Y",$timestamp);
$tag = date("l",$timestamp);
  if ($tag == "Saturday")
  {
echo "<a href=\"www.google.de\">Samstag</a>";
}
  if ($tag == "Sunday")
  {
echo "<a href=\"www.google.de\">Sonntag</a>";
}
  if ($tag == "Monday")
  {
echo "<a href=\"www.google.de\">Montag</a>";
}
  if ($tag == "Tuesday")
  {
echo "<a href=\"www.google.de\">Dienstag</a>";
}
  if ($tag == "Wednesday")
  {
echo "<a href=\"www.google.de\">Mittwoch</a>";
}
  if ($tag == "Thursday")
  {
echo "<a href=\"www.google.de\">Donnerstag</a>";
}
  if ($tag == "Friday")
  {
echo "<a href=\"www.google.de\">Freitag</a>";
}

My second question is that a good way of doing? or do you have some improvement suggestions because my php knowledge is very little :(
www.google.de I replace with the link to the album which I want to link on each weekday.
Thanks for your help.

Best Regards
Crazymodder

Crazymodder

I implement it in the theme.php now. I think that was the right way of doing ;)

Joachim Müller

Quote from: Crazymodder on January 03, 2009, 12:14:47 PM
So which file i have to edit the themes.inc.php or my theme.php.
Always edit themes/yourtheme/theme.php! Never edit includes/themes.inc.php! Has been asked and answered many times over. Is being explained in the docs. The file you're not suppossed to edit contains a corresponding note as well.

The coolest way to accomplish this is an associative array to avoid the endless if/then. Code looks like this:
<?php
$weekday_array 
= array(
    
'Saturday' => 'Samstag',
    
'Sunday' => 'Sonntag',
    
'Monday' => 'Montag',
    
'Tuesday' => 'Dienstag',
    
'Wednesday' => 'Mittwoch',
    
'Thursday' => 'Donnerstag',
    
'Friday' => 'Freitag',
);
echo 
'<a href="http://www.google.de">' $weekday_array[date("l",time())] . '</a>';
?>
Refer to the language files to see how this is done.
There's even better ways of doing this if you're just trying to come up with some date localization formats. However, this site is not the best place to learn PHP - there are better places for that on the web that are dedicated to just that. In fact, you can have PHP spit out the weekday by name already in a your local format - that's pretty straightforward.