This php script accomplishes 2 things. First, it turns error reporting on so that you can see if anything goes wrong and second, it sets the script up to accept AJAX calls from very specific sites. I already have it configured to accept calls from the Construct editor at preview.construct.net. You only need to change the mysite.com to the URL for your website.
After it checks to make sure the AJAX call is coming from the right places, it then loads up the news.php file.
Once you've edited the mysite, save this as myNews.php and upload it to the same directory as the Fusion News php files.
Now, in Construct. I started a new project and I need to place two objects on the layout. An HTMLElement and an AJAX.
To configure the HTMLElement we need to make a few changes to the properties.
- change the name to myNewsBox
- Under HTML, check the box "Text like HTML"
- Under HTML, erase the word 'text' from the text field.
- Under Inline Style, unckeck the box 'Use Preview Text'
- Under Inline Style, uncheck the box 'Auto Font Size'
- Under Inline Style, In the overflow-x dropdown, select hidden
- Under Inline Style, In the overflow-y dropdown, select auto
In the event sheet:
- Add a new event System On Start Of Layout and add an AJAX.requestURL action.
- Add the tag "myNews" and the url to your myNews.php. This should be on the same url you changed in the php file above.
Let's add in an error check.
- Add a new event, AJAX On Error with the tag "myNews". For the action, set the myNewsBox.text to "Server Error"
And finally, what to do with the news once the AJAX gets it.
- Add a new event Ajax On completed with the tag "myNews" For the action set the myNewsBox.text to AJAX.LastData.
Your event sheet should look a lot like like this:
Now, if you did everything correctly and you didn't get a server error, when you run the preview you should see something like this:
Now it may not look like much but here's the good part. Fusion News uses templates. If you know a little CSS you can easily go in and make some changes just to the template. For example: I can change the Fusion News Short & Long News template from this:
<h2>{cat_name}: {subject}</h2>
to this:
<h2 style="color:red">{cat_name}: {subject}</h2>
and get this:
Because of the templates in Fusion News, you can easily go in and create your own classes and tags and, with a bit of CSS imagination, make the news look exactly the way you want.