Advanced search  

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]

Pages: [1]   Go Down

Author Topic: actuel Albums  (Read 2115 times)

0 Members and 1 Guest are viewing this topic.

Crazymodder

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 117
actuel Albums
« on: January 03, 2009, 12:14:47 pm »

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

Crazymodder

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 117
Re: actuel Albums
« Reply #1 on: January 03, 2009, 02:39:05 pm »

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

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: actuel Albums
« Reply #2 on: January 04, 2009, 03:42:28 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:
Code: [Select]
<?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.
Logged
Pages: [1]   Go Up
 

Page created in 0.019 seconds with 19 queries.