Page 1 of 1

[Addon] Spot news placement

Posted: Sat Apr 23, 2011 11:33 am
by Snooper
Sometimes you need to inform customers of something new, changing or simply to keep interest. In my case, it was to keep customers upto date with our stock movements.

My solution, starts with this easy to install an addon. How this was mostly achieved is by exploiting an odd feature of ISC’s %%include function and its insistence of being uncompromising.

Firstly, make a side panel and call it (say) sitenews. Save this into yoursitetemplate/panels folder.

<div class="Block Moveable Panel SiteNews" id="SiteNews">
<h2>Site News</h2>
<div class="BlockContent">
<ul>
%%Include.calltophpscriptgoeshere%%
</ul>
</div>
</div>


Now create a folder call it News and in this place the following –

A text file with nothing in it named news.txt

Plus the php code below, calling this whatever you wish and can remember –

Code: Select all

<?
if ($_POST) {
// submit changes
$file = fopen($uploaddir . 'news.txt', 'w', 1);
fwrite($file, $_POST['textarea']);
fclose($file);
?>
<textarea name="textarea2" cols="17" rows="15"><?
include("news.txt");?></textarea>
<?
} else {
// display text and wait for changes
?>
<form name="outtext" method="post" action="?ac=outtext">
<textarea name="textarea" cols="17" rows="15"><?
include("news.txt");?></textarea>
<br><input type="submit" name="Submit" value="Submit"></form>
<?
}
?>
Now place the php script into a folder called /news and this in turn into the root of your shop hosting.

When called and used, this will display a textarea window for you to enter any text. Including html formatted. Once you ‘Enter’ this, the screen will display the now saved content of the textarea window into text.txt. You might need to refresh the screen if cache prevents this.

And to complete the link to the page where the text to be displayed add the following into the panel script (from above)-

%%Include.%%GLOBAL_ShopPath%%/news/news.txt%%

Image

Working example see here - http://www.ihost4u.co.uk/xcart2/

Re: [Addon] Spot news placement

Posted: Wed Apr 27, 2011 5:00 pm
by Tony Barnes
Could you not just have done a news panel and dropped the HTML into it? Interesting how this seems to work though

Re: [Addon] Spot news placement

Posted: Wed Apr 27, 2011 9:26 pm
by Snooper
Ahh.. yes indeed I could have gone that route. Only I went for the typical 'what if' and challenge angle. My what if, is what if the news panel way already being used and you perhaps needed additional output space come dynamic window. Hence this 'addon'.

The challenge is to learn as much as I can about the underbelly of ISC so I can resolve one or two mods/addons I have in pipe line. Plus as you may be aware, one or two that are not quite resolved.

Re: [Addon] Spot news placement

Posted: Thu Apr 28, 2011 4:06 pm
by Tony Barnes
Fair does mate, always good to learn stuff I guess!!