All,
I keep promising myself I’m going to write a Joomla component that will allow import of Sailwave results into a Joomla website, but I keep getting busy actually scoring regattas!
Still, I’ve been frustrated with the appearance of Sailwave results on Joomla sites - you pretty much either have to embed them into an article, or take the viewer away from your site by externally linking to a Sailwave-generated web page.
I took some time today to see what I could do about just reading a Sailwave-generated HTML file, plucking out the results (and the Sailwave trailer, of course) and inserting them automatically into a Joomla article.
One of the major issues is that Joomla natively doesn’t allow PHP in articles, but there are plugins that you can use. I used one called DirectPHP, which allows you to place PHP code directly into an article. There are others available.
The process goes like this:
-
Set Sailwave to upload to a known folder and file name on your website
-
When the results article on your Joomla website is opened, it goes out and gets that Sailwave file, trims out everything except the titles and results
-
The remaining results are then echoed into the article, along with whatever additional text or styling you want.
You can use just about any display style you wish for the original HTML file. I like having well-styled results page available for direct access as well, particularly when you need to print out results for an official bulletin board. This way I get both - the script goes to my stand-alone page, grabs the results, and displays them in the Joomla article.
Anyway, I thought this might help others, so here is the code I used. This is entered directly into a Joomla article - make sure you are using an editor that allows for source code editing, and you have installed something like the DirectPHP plugin. This one assumes the results are in a folder called “results” and the file is named “namresults.html”. Styling is at the top and easy to change - another reason I like this approach:
body {font: 80% arial, helvetica, sans-serif; text-align: center;} .hardleft {text-align: left; float: left; margin: 15px 0 15px 25px;} .hardright {text-align: right; float: right; margin: 15px 25px 15px 0;} table {text-align: left; margin: 0px auto 30px auto; font-size: 1em; border-collapse: collapse; border: 2px #008 solid;} td, th {padding: 4px; border: 1px #008 solid; vertical-align: top; color: black;} .caption {padding: 5px; text-align: center; border: 0;} th {background-color: #B0AEAE; font-weight: bold;} h1 {font-size: 1.6em;} h2 {font-size: 1.4em;} h3 {font-size: 1.2em;} p {text-align: center;} .even {background-color: #f0f0f0;} .odd {background-color: #fff;} .contents {text-align: left; margin-left: 20%;} .natflag {border: 1px #999 solid;width:28px;} .nattext {font-size: 0.8em;} .place1 {font-weight: bold; background-color: #ffffaa;} .place2 {font-weight: bold; background-color: #aaaaff;} .place3 {font-weight: bold; background-color: #ffaaaa;} .placen {} <?php // set source file name and path $source = "results/namresults.html"; $scorestart = "<h3 class="; $scoreend = ""; $scorestartKey = 0; $scoreendKey = 0; // read raw text as array $raw = file($source) or die("Cannot read file"); // join remaining data into string $data = join('', $raw); //find the substrings $scorestartKey = strpos ( $data , $scorestart ); $scoreendKey = strpos ( $data , $scoreend ); //pull out just the results and the Sailwave footer $html=substr ( $data , $scorestartKey , $scoreendKey-$scorestartKey ); //put it on the page echo $html; ?>Pretty simple, but it works. As soon as our event gets underway I’ll post a link to the results page so you can see what this looks like.