How to generate CSV file in cakePHP 2.x? - php

I am beginner in cakePHP and woking on cakePHP 2.0. I am trying to generate CSV file, to accomplish this task i am using the following method.
cake php official site refr.
github refr.
i have got stucked in step no. 2 when it is loading the plugin. the following error is occurring in app/Config/bootstrap.php file
Fatal error: Class 'CakePlugin' not found in /var/www/html/sitefolder/app/config/bootstrap.php on line 51
CakePlugin::load('Export');
Please correct me.
Thnaks

Thnaks guys for your precious response on this
For now i have find the solution of this by following steps.
download the plugin files form
https://github.com/joshuapaling/CakePHP-Export-CSV-Plugin
by pass the step no.2 and step no.3 of what they have mentioned in official refer.
copy the file "ExportComponent.php" from plugin and paste it in
site_folder/app/controllers/components
add it in controller's component array variable
$components = array('blabla1', 'blabal2', 'Export')
create $data array variable (which contains the csv file data ) and just do like
$this->Export->exportCsv($data, 'filename1.csv');
Its done and working fine for me

Related

JSON / JQuery - get_fields( ... ) confusion

Thanks in advance for any clarity:
I havent worked directly with JQuery or JSON till recently and currently have an issue I dont understand.
A wordpress plugin that displays a sort of tv schedule --> displays on the deployment server when added but not on my development server. When I add the plugin the page sends me the following error:
Uncaught Error: Call to undefined function get_field()
Here is the actual line of code:
$ScheduleDownload = get_field('tv_printable_schedule', 'options');
I'm uncertain but I have a feeling that that is a JSON query... however the code doesn't recognize it.
Is JSON / Jquery installed incorrectly? Am i simply missing a basic understanding?
Thanks for your assistance
Thanks everyone .. here was the answer that aynber & TOH19 hit correctly:
https://www.advancedcustomfields.com/resources/installation/
you need to install advanced custom fields via plugin on the WP site.
Thank you!

PHP Issue | Class Email Not found, Double Opt in form

So I recently came across this tutorial for creating a double opt in script. But it does not seem to be working.
Can someone check it out and see what's wrong with it?
Every time I try to use it, I get the error
Class 'Email' not found in register.php at line 12
Here is the link to the article: http://tonygaitatzis.tumblr.com/post/66610863603/double-opt-in-email-registration
Here is the github link for the download: https://github.com/backupbrain/double-opt-in-registration-php
In the register.php only emailregistration class is loaded.
But at line 12, you are trying to create instance of class email which is not loaded in this php file.
Load this class before using it in the code
require_once('classes/Email.class.php');

How to add comments to each forum post in yii, using bbii forum module and comments-module

I am using Yii bbii forum module and it works fine. But now I want to add comments-module so every forum post could be seperately commented.
At the begining it might look:
I followed instruction what is here, but I can't make it work :(
And why I even need to include this file, if I want to add just comment?
When I added the same widget to user page (just for testing) - I got "This item cann't be commentable" and it's fine because probably I don't have correct configuration in main.php.
Difference between widget in user model view and forum view is data passed in it.
Here:
public function actionPostComment()
{
if(isset($_POST['Comment']) && Yii::app()->request->isAjaxRequest)
{
$comment = new Comment();
$comment->attributes = $_POST['Comment'];
var_dump($comment);
var_dump returned this when tried to submit comment in forum, and here in user view page.
And probably it is not even possible to combine these to modules? I'm really new in Yii.
Updated:
Basically what I have done is:
exstracted comment module (under protected->modules)
in main.php (under protected->config) added all cofiguration in modules array:
'comments'=>array(
//you may override default config for all connecting models
'defaultModelConfig' => array(
//only registered users can post comments
'registeredOnly' => false,
'useCaptcha' => false,
.......
and in view file _post.php added following:
<?php $this->widget('comments.widgets.ECommentsListWidget', array(
'model' => $data,
));
and var_dump($data) gives this (when this is called in controller where post is reseaved).
An error message was given here:
include(BbiiPost.php): failed to open stream: No such file or directory
You said that the Bbii was working with Yii and it broke when you tried to add comments.
The links to your var_dump files are broken, but I did try to read them ;)
It looks like the comments module is interfering with the POST path so that when the form submission comes in it is in a different path from the root which is confusing the YiiBase's autoloader.
You could try explicitly adding the path to BbiiPost.php to the autoloader's search path, or finding where the include("BbiiPost.php") line is and changing it to an absolute path.
Another possibility is that the forum page you are on has links to add comments but the page routing has not been taken from the route. So it might be that the POST link to the comments is actually at /forum/123/comment/add instead of just /comment/add. So when the form is submitted it is trying to the comments/add controller/action but finding that it is in /forum/view and getting confused about the paths to the include files.
I have generally found that the instructions on the Yii (v1) [v2 docs are much better] site for these modules is flaky at best. Quite often the source download link on the page points to an old buggy version of the code as the project has usually moved somewhere else. You generally need to have a pretty good PHP/Yii knowledge to debug these user-submitted modules and get them working.

How to configure Vimeo-Service-module in Silverstripe

Forgive me for my English
I am new in PHP. And I'm building a site using Silverstripe and trying to configure Vimeo-Service-module. I'd follow the steps from this link
https://github.com/r0nn1ef/Silverstripe-Vimeo-Service-module
I did everything that mentions in the article. And created a page in admin panel of VimeoGallery page type and set the parameters on Videos tab to grab the videos for display.
After created page, I visited my and clicked on video menu but then all I see is no videos returned. It is showing blank page and no any error messages.
Is that I've done anything wrong. Please guide me...
Thanks in advance.
OK, I think I see the issue here. You are calling VimeoService::setAPIKey() however accessing the method like that is deprecated in the new version (the 2.0 branch - I was incorrect in my comment when I mentioned master) of the module.
The module instead uses the Site Config in the CMS to set the API key and a few other settings.
Now just remove VimeoService::setAPIKey() from your _config.php file, run /dev/build and set the API key through the CMS.
EDIT
On line 142 of VimeoGalleryPage.php, there is a function called flushCache. Replace the code in that function with the following:
public function flushCache($persistent = true) {
parent::flushCache($persistent);
unset($this->_cachedVideos);
}
Basically, the code in the 2.0 branch for this function does not correctly extend the same named function in SiteTree.

add JsonP-Format for callback function to restler

I´m trying to add JSONP Format to lucarest restler api without luck
As mentioned in this thread
jsonpsupport
i added a new file jsonpformat.php with the given context into my vendor/ folder where
restler.php resides.
Then i added the
$r->setSupportedFormats('JsonpFormat','JsonFormat', 'XmlFormat');
to my index.php but restlerExlorer does´t fire up anymore and the server logs says
...RestException' with message 'Class 'JsonpFormat' not found'...
But i put it into the folders that were stared in the thread...
Help would be great.
Thx
Inge
We took the suggestion in the same thread and named our JSONP format as JsFormat
So just use
$r->setSupportedFormats('JsFormat','JsonFormat', 'XmlFormat');

Categories