Integrate Cutenews CMSimple XH 1.6.1

General questions about CMSimple
Post Reply
laan
Posts: 2
Joined: Sun Feb 02, 2014 6:39 pm

Integrate Cutenews CMSimple XH 1.6.1

Post by laan » Sun Feb 02, 2014 6:58 pm

Hi,

I am writing this request to ask you an help about the new plugin system in CmSimple XH 1.6.x. In details since version 1.5.x I integrate external code like cutenews simply inserting some code lines at the end of index.php file inside plugins folder. In details to make the news open inside the cmsimple template I add this code lines:

Code: Select all

$shownumber=10;

$cute_page='News';

if($u[$s]==$cute_page&&!($edit&&$adm)&&$s>-1){
ob_start();
$number=$shownumber;
include("./cutenews/show_news.php");
$c[$s].=ob_get_contents();
ob_end_clean();
}

$cute_parameter=$_GET['subaction'];

if($cute_parameter==''){
$cute_parameter=$_GET['start_from'];
if($cute_parameter!='')$number=$shownumber;
}

if(($cute_parameter!=''))
{
$s=-1;
ob_start();
$number=$shownumber;
include("./cutenews/show_news.php");
$o.=ob_get_contents();
$title=ucfirst($cute_parameter);
if($title=="Showfull")$title='Show Article';else $title='News';
ob_end_clean();
}
Now how do I have to change the code to insert cutenews as usual?

Thanks in advance for your help!

cmb
Posts: 12893
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Integrate Cutenews CMSimple XH 1.6.1

Post by cmb » Sun Feb 02, 2014 7:48 pm

laan wrote:I am writing this request to ask you an help about the new plugin system in CmSimple XH 1.6.x.
Well, the plugin system in CMSimple_XH 1.6 is not new; actually, it has been mostly an internal rewrite to fully integrate the pluginloader with CMSimple_XH. Old plugins should basically still work.
laan wrote:In details since version 1.5.x I integrate external code like cutenews simply inserting some code lines at the end of index.php file inside plugins folder.
That wasn't the best way in earlier versions, anyway. Basically, it didn't matter where you insert such code, so it was reasonable to make a new plugin (this way you could simply install the plugin again, after updating to a new version).

So just create a new folder plugins/cutenews/ and add a file index.php with the code you've posted above. Don't forget to put in the following as first line:

Code: Select all

<?php
Please note, however, that simply including other PHP scripts might have side effects, as names of variables, functions etc. may clash, so this technique may work or not. Usually, it's better to handle such external scripts in an IFrame, but that may not be possible in this case.

It seems you're using the cutenews.php script from http://www.cmsimple.org/archives/cmsimp ... nd_plugins that allows to integrate CuteNews. I'm quite surprised that this solution works, apparently.
Christoph M. Becker –Plugins for CMSimple_XH, but not for CMSimple 4+

laan
Posts: 2
Joined: Sun Feb 02, 2014 6:39 pm

Re: Integrate Cutenews CMSimple XH 1.6.1

Post by laan » Sun Feb 02, 2014 8:31 pm

I have tried to integrate cutenews as a plugin as suggested. But after the try there are no results. I'm able to integrate the news in the template but I'm not able to see the news open as a full news.

The system show me these errors:
NOTICE: Undefined offset: -1
C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localweb\projects\padova_21-12-2013\plugins\cutenews\index.php:7
NOTICE: Undefined index: subaction
C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localweb\projects\padova_21-12-2013\plugins\cutenews\index.php:15
NOTICE: Undefined index: start_from
C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localweb\projects\padova_21-12-2013\plugins\cutenews\index.php:18
I think that before the update some variables were global while now they are become local or something like that.

Now how do you suggest that I can solve my issue? If it is possible I prefer a clean solution that I can use also in the future. I'm a c++ programmer so it's only a matter of understand what it has to be done with the PHP code + CmSimple to which I'm not used to.

Thanks again for your help!

cmb
Posts: 12893
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Integrate Cutenews CMSimple XH 1.6.1

Post by cmb » Sun Feb 02, 2014 9:36 pm

laan wrote:I'm a c++ programmer so it's only a matter of understand what it has to be done with the PHP code + CmSimple to which I'm not used to.
Well, what the script you've posted does, is somewhat similar to #include header files and linking to libs of another application. That is asking for trouble. It might work with certain versions of A and B, but may fail with others, however, there's no warranty that both applications stay the same over time.

I've downloaded a copy of CuteNews 2.0, and it seems it is meant as stand-alone application. So the simplest solution is to use it as such. You can include the show_news.php script on a page in an IFrame:

Code: Select all

<iframe src="./cutenews/show_news.php" frameborder="0">
This way both applications are insulated, and should work flawlessly together. The only drawback AFAICS is that the IFrame will not resize as desired; you can use the Wrapper plugin with autowrap() or autowrap2() which will resize the IFrame. Just try if it works for you (disable or remove the cutenews plugin in the meantime).

A completely different option might be to use a CMSimple plugin to manage and present the news instead of CuteNews. I don't know CuteNews, and I don't know which features you actually need, but you may consider to have a look at available News Plugins (the News plugin might be a good start).
Christoph M. Becker –Plugins for CMSimple_XH, but not for CMSimple 4+

Post Reply