Easy PHP Calendar Script

Go Back   Easy PHP Calendar > General Discussion > Customizations (Themes / Templates)

Customizations (Themes / Templates) Help with customizing the themes and templates. Post your own custom themes for others to enjoy.

Closed Thread
 
Thread Tools Search this Thread Display Modes

Dynamic links by day
Old 07-29-2010, 04:33 AM   #1
4arter
Calendar User
 
4arter is offline
Join Date: Jul 2010
Posts: 7
Default Dynamic links by day

On 11-18-2007 there is a posting "Creating dynamic links based on Month". I would like to get the same thing except based on days. The code for a month dynamic link posted there is
Code:
$pathToFile="/forms/";
if (isset($_REQUEST['mo']) && isset($_REQUEST['yr'])) {
    $file=$pathToFile.date("My", mktime(0,0,0,$_REQUEST['mo'],1,$_REQUEST['yr']))."pdf";
} else {
    $file=$pathToFile.date("My")."pdf";
}
In my case, our bridge club software creates results files based on the date and general time of day. For example 100728E.htm is a file for the July 28, 2010 evening game. I want to put in the same link on every game event date (about 200 per year). Though I might be able to guess how to make the code above work for days, I would be using trial and error methods. I don't mind making three links, with (M)orning, (A)fternoon, and (Evening) hard coded, because all games on any weekday will always be at the same time.

If it is not too hard, can you revise this example?

Here is a link to the original posting:
http://www.easyphpcalendar.com/forum...=dynamic+links
 

Old 07-29-2010, 06:54 AM   #2
ve9gra
Support Team
 
ve9gra's Avatar
 
ve9gra is offline
Join Date: Jun 2003
Location: New Brunswick, Canada
Posts: 4,453
Default

That code is not meant to be inserted in an event - in fact, it will simply not work.

Look into the Description Parser in the Online Docs - Event Manager.
__________________
-- Gervais
EPC Tutorials... We're here to help!
Offering custom integration services. Contact me here.
* Not affiliated with EasyPHPCalendar or NashTech Inc.
 

Description Parser
Old 07-30-2010, 01:33 AM   #3
4arter
Calendar User
 
4arter is offline
Join Date: Jul 2010
Posts: 7
Default Description Parser

I tried to get any field to display for a couple of hours and did not. I'm missing something. And even if I figure out the basics, I'm not at all convinced that I can make the kind of dynamic link I need. I would have to pick apart the date and reassemble it into a string to match the standard file naming system used by Bridge scoring software.

I will probably move on to a brute force method (create links in a spreadsheet, then import the resulting html static links into the database), which is something I know more about.

But I am still curious about what I am not doing right. Are there a few lines of code I can paste into an event description that will display the date? Just to check that I can really do it. It's also a way to check if I have all settings correct.

Thanks.
 

Old 07-30-2010, 08:18 AM   #4
ve9gra
Support Team
 
ve9gra's Avatar
 
ve9gra is offline
Join Date: Jun 2003
Location: New Brunswick, Canada
Posts: 4,453
Default

There is no "code" at all that can be put in the description. You can put tags in the description, and the parser will replace them with the value.

[date] will give you the date.

What you can do is create a middle-man page, and pass the date as a variable. Then your middle-man will convert the date format from EPC into the matching date format for your bridge software and then feed that page.

So the links in the event description would be your.web.site/middle-man.php?d=[date]&p=X where X is M, A, or E.

And the code inside of middle-man.php would be something like this (note: code not tested, I've probably screwed up my parentheses somewhere)

PHP Code:
<?php
$pathToFile 
""//define where your .htm files are
$periods = array("M","A","E");
// to stop processing if date isn't passed
if ((!isset($_REQUEST['d'])) || ($_REQUEST['d']=="") || (!isset($_REQUEST['p'])) || ($_REQUEST['p']="") || (!in_array(strtoupper($_REQUEST['p']), $periods))) {
    echo 
"<H1>Invalid parameters.</H1>";
    break;
} else {
    
$dateFromEPC $_REQUEST['d'];
    
$dateParts explode("."$dateFromEPC);
    
$myDateFormat date("ymd"mktime(0,0,0$dateParts[0], $dateParts[1], $dateParts[2]));
    
$period strtoupper($_REQUEST['p']);
    include(
$pathToFile.$myDateFormat.$period.".htm");
}
?>
__________________
-- Gervais
EPC Tutorials... We're here to help!
Offering custom integration services. Contact me here.
* Not affiliated with EasyPHPCalendar or NashTech Inc.
 

Update and a coding request
Old 08-04-2010, 04:32 PM   #5
4arter
Calendar User
 
4arter is offline
Join Date: Jul 2010
Posts: 7
Default Update and a coding request

First, an FYI. Of all the examples I saw for Description Parser, all were PHP. My confusion was that I thought that php was somehow required to view the available tags. Thanks for your answer.

Now that I know that what I want can be done, but I don't think I can do it without spending lots of time learning more PHP, would you or someone else like to finish the coding for my needs? I will pay a reasonable fee.

I made a php file scorefinder.php based on the example above, and got an error. Here is what I tried.

<?php
$pathToFile = "http://clubresults.acbl.org/Results/196253/2010/07/"; //define where your .htm files are
$periods = array("M","A","E");
// to stop processing if date isn't passed
if ((!isset($_REQUEST['d'])) || ($_REQUEST['d']=="") || (!isset($_REQUEST['p'])) || ($_REQUEST['p']="") || (!in_array(strtoupper($_REQUEST['p']), $periods))) {
echo "<H1>Invalid parameters.</H1>";
break;
} else {
$dateFromEPC = $_REQUEST['d'];
$dateParts = explode(".", $dateFromEPC);
$myDateFormat = date("ymd", mktime(0,0,0, $dateParts[0], $dateParts[1], $dateParts[2]));
$period = strtoupper($_REQUEST['p']);
include($pathToFile.$myDateFormat.$period.".htm");
}
?>

My event link looked like this:

<a target="_blank" href="http://www.wvbridge.com/calendar/scorefinder.php?d=[date]&p=E">
Score Finder</a>

The actual PHP needed will be another step more complicated because of the year and date in the link to scores. The path to the file really needs to be $pathToFile = "http://clubresults.acbl.org/Results/196253/ and the php needs to add year/month/date.htm in the format YYYY/MM/YYMMDD(M, E, or A).htm

Here is a working score link for July 13, 2010: http://clubresults.acbl.org/Results/...07/100713E.HTM

If you need it, I'll provide an ftp account for testing.

If you don't do this, can you make a recommendation?

Last edited by 4arter; 08-04-2010 at 04:36 PM.
 

Old 08-05-2010, 06:31 AM   #6
ve9gra
Support Team
 
ve9gra's Avatar
 
ve9gra is offline
Join Date: Jun 2003
Location: New Brunswick, Canada
Posts: 4,453
Default

Oh shoot.... I thought that the files were on your own server... That's why I used the include() function. Now that I know the actual destination of the files and their full name format, I should be able to tweak the code accordingly.

I'll post back later.
__________________
-- Gervais
EPC Tutorials... We're here to help!
Offering custom integration services. Contact me here.
* Not affiliated with EasyPHPCalendar or NashTech Inc.
 

Old 08-05-2010, 06:58 AM   #7
ve9gra
Support Team
 
ve9gra's Avatar
 
ve9gra is offline
Join Date: Jun 2003
Location: New Brunswick, Canada
Posts: 4,453
Default

Ok, I found one error in my code (missed one "=" somewhere), and I've modified it so that it would allow files on a remote server.

PHP Code:
<?php
$pathToFile 
""//define where your .htm files are
$periods = array("M","A","E");
// to stop processing if parameters aren't passed
if ((!isset($_REQUEST['d'])) || ($_REQUEST['d']=="") || (!isset($_REQUEST['p'])) || ($_REQUEST['p']=="") || (!in_array(strtoupper($_REQUEST['p']), $periods))) {
    echo 
"<H1>Invalid parameters.</H1>";
} else {
    
$dateFromEPC $_REQUEST['d'];
    
$dateParts explode("."$dateFromEPC);
    
$datePathFormat "Y/m/ymd"//adjust the format for your situation
    
$myDateFormat date($datePathFormatmktime(0,0,0$dateParts[0], $dateParts[1], $dateParts[2]));
    
$period strtoupper($_REQUEST['p']);
    
////use this if the files are local
    //include($pathToFile.$myDateFormat.$period.".htm");
    ////use this if the files are remote
    
header('Location: '.$pathToFile.$myDateFormat.$period.'.htm');
}
?>
All you need to do is add the location of your files in the $pathToFile variable. I've tested it this time and it works for real.

If you are so inclined, you can make a donation to my coding fund. Simply visit my website and you'll find the button there.
__________________
-- Gervais
EPC Tutorials... We're here to help!
Offering custom integration services. Contact me here.
* Not affiliated with EasyPHPCalendar or NashTech Inc.

Last edited by ve9gra; 08-05-2010 at 07:00 AM.
 
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I specify the target for all links riddler General Support 1 06-14-2008 06:37 AM
Changing Calendar Day Links whsjr86 General Support 7 02-22-2008 12:48 PM
Creating dynamic links based on Month scott.mikesell General Support 2 11-19-2007 09:37 PM
getting day to display jernigani Customizations (Themes / Templates) 3 12-05-2006 02:53 PM



All times are GMT -4. The time now is 10:31 PM.


vBulletin skins developed by: eXtremepixels
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 2009 NashTech, Inc.

| Home | Register | Today's Posts | Search | New Posts |