Hi there!!
I'm not a very contributive on this forums, but I've got a piece of code someone might need. Also, sorry for my english.
FEATURES:
If you have a Wordpress webpage (If people ask I might add support for joomla or another cms) you can use this plugin to show the last post under a certain category.
STATUS:
Just right now I've acomplished to push it the post excerpt via alert message, but I wanna make it show on a modificated Title Scene, just a WIP.
I've got a Little question to whoever can answer/help me:
So, the result of a JSON GET is an array. The way to parse it is:
var text = result.posts[0].excerptIs anyway to make the excerpt a variable where I, or the user, could change the value via parameter to get another result?
EDIT: The code so far
Just trying to improve it and learning.
Thanks.
I'm not a very contributive on this forums, but I've got a piece of code someone might need. Also, sorry for my english.
FEATURES:
If you have a Wordpress webpage (If people ask I might add support for joomla or another cms) you can use this plugin to show the last post under a certain category.
STATUS:
Just right now I've acomplished to push it the post excerpt via alert message, but I wanna make it show on a modificated Title Scene, just a WIP.
I've got a Little question to whoever can answer/help me:
So, the result of a JSON GET is an array. The way to parse it is:
var text = result.posts[0].excerptIs anyway to make the excerpt a variable where I, or the user, could change the value via parameter to get another result?
EDIT: The code so far
Code:
//======================================================// WebpageNews//======================================================/*: * @plugindesc WebPageNews ------------------------------------------------------- * @author Jhin ------------------------------------------------------- * @param Webpage * @desc Webpage URL, please, maintain the http:// and the final slash. * Example: [URL="http://example.com/%C2%A0*"]http://example.com/ *[/URL] @default [URL="http://example.com/%C2%A0%C2%A0*"]http://example.com/ *[/URL] @param Category * @desc Category ID. Check the help for more info. * Example: 1 * @default 1 * @param Data * @desc Data to retrieve. * Example: content ==OPTION NOT WORKING=== * @default content * @help=============================================================WARNING: This plugin in experimental phase.=============================================================WARNING: This plugin needs to work the JSON API plugin for wordpress, you cand find it on the Install Plugin options inside your Admin Dashboard.============================================================= * Category ID-----------------To Know wich category ID you must fill, please check this nicetutorial:http://www.wprecipes.com/how-to-find-wordpress-category-id * Content-----------------======= AT THIS TIME, THIS OPTION DOES NOT WORK =============DOCs in the way*/ (function() { // If the user changes the Plugin name, then the parameters // doesn't works. Let's inform 'bout that. // = Thanks to Ramiro for this piece of code if(!Object.keys(PluginManager.parameters('JHN_BeatersJSON')).length) { throw new Error("It seems than you named 'JHN_BeatersJSON' differently, this plugin won't work that way!"); } // Using the parameters var parameters = PluginManager.parameters('JHN_BeatersJSON'); var webpagedomain = String(parameters['Webpage']); var categoryid = String(parameters['Category']); var data = String(parameters['Data']); var jsonurl = webpagedomain + '?json=category_id=' + categoryid; // Doing the magic var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { var result = JSON.parse(xmlhttp.responseText); var text = result.posts[0].content // Let's replace the ugly characters trimmedtext = text.replace("<p>", "").replace("</p>", "").replace(/–/g, "-"); alert(trimmedtext); } } xmlhttp.open("GET", jsonurl, true); xmlhttp.send(); })();
Thanks.