Simplepie set_feed_url feed - feed

and thanks in advance for your help. I'm using Simplepie to try to bring this feed:
http://www.p2rx.org/webservices/rssNews.cfm?Type=Tribal&getall=true
into this page:
http://www.tribalp2.org/events/news.php
As you can see, it isn't working. Although many other feed urls I've entered into:
$feed->set_feed_url('http://www.p2rx.org/webservices/rssNews.cfm');
work just fine. I've added
$feed->force_feed(true);
as well. What might the problem be? The full code is:
<?php
require_once('../php/autoloader.php');
$feed = new SimplePie();
$feed->set_feed_url('http://www.p2rx.org/webservices/rssNews.cfm?Type=Tribal&getall=true');
$feed->force_feed(true);
$feed->init();
$feed->handle_content_type();
?>
<?php foreach ($feed->get_items(0,30) as $item): ?>
<div class="item">
<h4><?php echo $item->get_title(); ?> - <?php echo $item->get_date('F j, Y'); ?></h4>
<p><?php echo $item->get_description(); ?></p>
</div>
<?php endforeach; ?>
<?php unset($feed); ?>
Thanks.

SimplePie can not display all feeds. There are crap feeds that do not follow the standards and even if you try to force it, SimplePie can not decipher them. However checking http://validator.w3.org/feed/ your feed validates.
Try not forcing feed, also try calling force feed after init. If the feed validates SimplePie should handle it.

Related

Getting HTML of a Cake PHP form

I am creating a form using Cake PHP. Is there any way to retrieve the basic HTML of the created form. For example,if we use Form Helper, we can create form using PHP itself. But now, I need only the html part of the created form for other use. Is it possible to retrieve it??
For example, say if I give input form like,
<?php
echo $this->Form->create('User');
echo $this->Form->input('email');
echo $this->Form->end('Save');
?>
I need output like this
<form action="index.html">
<input type="email" />
<input type="submit" value="Save" />
</form>
I can even create seperate function for attaining this objective. But I would like to know, if there is any other method for achieving this output
you can store FormHelper output in a string variable
<?php
$html_string = '';
$html_string .= $this->Form->create('User');
$html_string .= $this->Form->input('email');
$html_string .= $this->Form->end('Save');
?>
and then use your string elsewhere. But I'm not sure this is what you're searching for.
If I understand the question correctly, you want to use the form you created on another part of your site?
If that is the case, I would put the form itself in an Element and then call the Element wherever I wanted the form.
View/Elements/form.ctp
<?php
echo $this->Form->create('User');
echo $this->Form->input('email');
echo $this->Form->end('Save');
?>
Then in any view on your site you can call the Element using:
<?php echo $this->element('form');?>

Date format in a function WordPress ACF

I have asked a similar question in the past but still have issues...
I am therefore placing the whole function here.
Can anyone tell me how to change the format that the date is output?
Currently it shows 20130731
I want it to show 31st July 2013
function le_detail() {
?>
<div class="event">
<!--Standard WP - use 'echo' -->
<h2 class="button"> <?php echo get_the_title(); ?> </h2>
<!-- ACF - NO 'echo' -->
<h3><?php the_field('where'); ?></h3>
<h3><?php the_field('when'); ?></h3>
<p><?php the_field('description'); ?></p>
<p>Chairman: <?php the_field('chairman'); ?></p>
</div>
<?php
}
The date is the line: (this is using the Advanced Customs Fields plugin)
<h3><?php the_field('when'); ?></h3>
Yes, I had this same problem until I tried it this way:
$date = DateTime::createFromFormat('Ymd', get_field('my_datefield'));
//use your field name
then...
<li>Ticket Date: <?php echo $date->format('d M, Y'); ?> </li>
Good Luck!
ACF plugin is having get_field('') function to get the value of the custom field. Since you have used 'when' as the field name, so do as follows:
<h3><?php echo date("dS F,Y",strtotime(get_field('when'))); ?></h3>
Use the above code snippet, that will solve your problem.

moving columns from left to right on homescreen

I'm working on magento and I want the categories that appear on left to be appeared on right side. I tried many tutorial, but didnt get it. Please help me on this. I'm new to magento. Thanks.
To add categories into the sidebar firstly go to:
app/design/frontend/default/YOURTHEME/template/catalog/navigation
and create a .phtml file, for example: left-nav.phtml
In left-nav.phtml put this:
<div class="category-nav">
<div class="block-content">
<p class="block-subtitle"><?php echo $this->__('Categories') ?></p>
<ul id="nav_category" class="nav_category">
<?php foreach ($this->getStoreCategories(true) as $_category): ?>
<?php echo $this->drawItem($_category) ?>
<?php endforeach ?>
</ul>
</div>
</div>
This just loops through all the enabled categories and outputs them into a list.
Now you need to link up the list so firstly go into /public_html/app/design/frontend/default/sbs/layout/page.xml
Find the bit for 2columns-left, or right if you want it to output on the right. In the layout you are using find:
<block type="core/text_list" name="left" as="left" translate="label">
Inside the block add a line of code like this:
<block type="catalog/navigation" name="category.listing" as="left_nav" before="-" template="catalog/navigation/left_nav.phtml" />
The before=”-“ just adds it before everything else.
Finally go into:
/public_html/app/design/frontend/default/YOURTHEME/template/page/2columns-left.phtml and add:
<?php echo $this->getChildHtml('left_nav') ?>
Note:
You will need to clean the cache for this to work.
I have written a more in depth answer on my website http://brideo.co.uk/moving-categories-to-left-collumn-magento/

where to write jquery ajax in yii form

I"m trying to write custom auto complete for text field. can anyone pls tell me where to write this jquery, ajax code for this textfield in yii..
<div id="output" class="row">
<?php echo $form->labelEx($model,'id'); ?>
<?php echo $form->hiddenField($model,'id'); ?>
<?php echo $form->textField($model,'id');
'$(function () {
$("#search").change(function(){
$.ajax({url:BASE_URL + '/controller/lookup/',
type:"POST",
data:this.value,
success:function(data){
$("#output").html(data);
}
});
});
});'?>
any help pls,
Many Thanks
Try Yii::app()->clientScript->registerScript instead of Yii::app()->getClientScript()->registerScript
You should just make a new file, call it, 'myFuncs.js'. Place in a directory within your Yii Web App.
Then, in your view, simply call the js file.
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/path/to/your/scripts/myFunc.js');

Zend_Currency Displaying Extra Character

I was trying to use Zend_Currency to format my currency outputs and i face this queer problem. An illegal character(Â) gets displayed along with the output of the currency data. The code i used is:
$currency = new Zend_Currency('en_IN');
echo $currency->toCurrency(100);
And the output is:
Rs 100.00
I dont know from where the "Â" comes up. I found out that this problem occurs for certain locales only. It is working fine for en_US and some others but output this extra char  in many other. Some one please help.
Put this in your layout header, this is an regular encoding issue.
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
To expand on Elzo's answer, I have this in my Bootstrap.php:
$this->bootstrap('view');
$view = $this->getResource('view');
$view->headMeta()->setHttpEquiv('Content-Type', 'text/html; charset=utf-8');
This is in my layout:
<head>
<?php echo $this->headMeta(); ?>
<?php echo $this->headTitle(); ?>
<?php echo $this->headLink(); ?>
<?php echo $this->headScript(); ?>
</head>