[Addon] Spot news placement

For Articles relating to more than one ISC version
Post Reply
Snooper
Posts: 264
Joined: Sat Jun 26, 2010 9:22 pm

[Addon] Spot news placement

Post 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/
Last edited by Snooper on Wed Apr 27, 2011 9:33 pm, edited 3 times in total.
ISC 5.5.4 Ultimate : Being used here -- http://www.kdklondon.com
Tony Barnes
Posts: 744
Joined: Thu Jun 18, 2009 8:59 am

Re: [Addon] Spot news placement

Post 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
Snooper
Posts: 264
Joined: Sat Jun 26, 2010 9:22 pm

Re: [Addon] Spot news placement

Post 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.
ISC 5.5.4 Ultimate : Being used here -- http://www.kdklondon.com
Tony Barnes
Posts: 744
Joined: Thu Jun 18, 2009 8:59 am

Re: [Addon] Spot news placement

Post by Tony Barnes »

Fair does mate, always good to learn stuff I guess!!
Post Reply