i installed the plugin and cannot find anything that tells me how it works and how to use it.
i have the icon in place and an empty onClick event
in homeSuccess.php:
<input class='submit_img' type="image" src="/images/rainbow/feed-icon-14x14.png" value="Feed" alt="Feed" onClick="gotoFeed(this.value,<?php echo $usr_profile->getId();?>)">
gotoFeed JS in homeSuccess.php:
function gotoFeed(id)
{
console.log("testing");
//must redirect to feeds page??
}
in the actions class:
public function executeFeed(sfWebRequest $request)
{
$profile_id = $this->getUser()->getAttribute('profile_id','zero');
}
can anybody help please?
thanks
You can find the complete tutorial at this link sfFeed2Plugin, just clicking the tab Readme
UPDATE
I'm using this plugin with an action like this in my action class:
public function executeFeedRss(sfWebRequest $request)
{
$feed = new sfRss201Feed();
$feed->setTitle('MySite');
$feed->setLink($this->generateUrl('#homepage'));
$c = new Criteria;
$c->addDescendingOrderByColumn(PostPeer::CREATED_AT);
$c->setLimit(10);
$Posts = PostPeer::doSelect($c);
foreach ($Posts as $post)
{
$item = new sfFeedItem();
$item->setTitle($post->getTitle());
// according to routing rule
$item->setLink($this->generateUrl('#posts', array('id'=>$post->getId())));
$item->setPubdate($post->getCreatedAt('U'));
$item->setUniqueId($post->getSlug());
$item->setDescription($post->getBody());
$feed->addItem($item);
}
$this->feed = $feed;
}
and this code inside the template feedRssSuccess.php:
<?php decorate_with(false) ?>
<?php echo $feed->asXml(ESC_RAW) ?>
Finally simply I have a link to this action in my layout through a template, but of course in a pageSuccess.php is the same.
I hope this can help you.
Related
please help me, this is simple thing but I don't know why this still keep error for an hour,
on my view I've got :
<a href="admin/editProduct?idd=$id">
on my controller that directed from above :
public function editProduct(){
$data["id"] = $_GET['idd'];
$data["produk"] = $this->model_get->get_data_list(2);
//this below doesn't work either, i just want to past the parameter to my model
//$data["produk"] = $this->model_get->get_data_list($_GET['idd']);
$this->adminHeader();
$this->load->view("adminPages/editProduct", $data);
$this->adminFooter();
}
I can not use the array id. It keeps telling me undefined variable idd.
I don't know what to do anymore, please anyone help!
I am using Codeigniter framework
Change your view as:
<a href="admin/editProduct/<?php echo $id;?>">
And in the controller, either get the id as parameter,
public function editProduct($id) {
}
or as uri segment
public function editProduct() {
$id = $this->uri->segment(3);
}
Change your link (in view) with this
<a href="admin/editProduct/$id">
And change your controller as
public function editProduct($id) {
}
Then user $id inside your controller
Make the href link as follows:
...
And edit the controller like this:
public function editProduct($id){
...
$this->model_get->get_data_list($id);
}
Where $id will be the passed $id.
make
try this this works fine
public function editProduct()
{
$id=$this->uri->segment(3);
$data["produk"] = $this->model_get->get_data_list($id);
$this->adminHeader();
$this->load->view("adminPages/editProduct", $data);
$this->adminFooter();
}
I'm creating a new block and I want to pass a defined variable to the block instance on add.
In my controller, I have the following:
// declare the var
public $hasMap = 0;
public function add() {
$this->set('hasMap', $this->generateMapNumber());
}
The generateMapNumber() function looks like this:
public function generateMapNumber() {
return intval(mt_rand(1,time()));
}
In my add.php form I have a hidden field:
<?php $myObj = $controller; ?>
<input type="hidden" name="hasMap" value="<?php echo $myObj->hasMap?>" />
When I create a new block, hasMap is always 0 and the hidden input value is always 0 too. Any suggestions? Thank you!
--- EDIT ---
From the concrete5 documentation:
// This...
$controller->set($key, $value)
// ... takes a string $key and a mixed $value, and makes a variable of that name
// available from within a block's view, add or edit template. This is
// typically used within the add(), edit() or view() function
Calling $this->set('name', $value) in a block controller sets a variable of that name with the given value in the appropriate add/edit/view file -- you don't need to get it from within the controller object. So just call <?php echo $hasMap; ?> in your add.php file, instead of $myObj->hasMap.
It will not be the same value, because the function will give diferrent values every timy it is called.
So here's the solution. In the controller...
public $hasMap = 0;
// no need for this:
// public function add() { }
public function generateMapNumber() {
if (intval($this->hasMap)>0) {
return $this->hasMap;
} else {
return intval(mt_rand(1,time()));
}
}
And then in the add.php file...
<?php $myObj = $controller; ?>
<input type="hidden" name="hasMap" value="<?php echo $myObj->generateMapNumber()?>" />
It works perfectly. On add, a new number is generated and on edit, the existing number is drawn from the hasMap field in the db.
Thanks for all the input. Hope that helps someone else!
Can someone help me achieve multiple zend pagination in a view using ajax. I have managed to achieve single pagination no problem, but now i want to perform more than 1.
this is my setup:-
added to the bootstrap:-
public function _initPaginator(){
Zend_Paginator::setDefaultScrollingStyle('Sliding');
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_control.phtml');
}
'pagination_control.phtml' has been taken from the zend framework manual.
added to the controller:-
public function init()
{
parent::init();
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('view', 'html')
->initContext();
}
added this to the controller action:-
public function viewAction()
{
$query = $this->_em->createQueryBuilder()
->select('t')
->from('Ajfit\Entity\Ticket', 't')
->where('t.engineerFk = :engineer')
->orderBy('t.dt', 'desc')
->setParameter('engineer', $engineer)
->getQuery();
$paginator = new Paginator($query);
$adapter->getIterator();
$zend_paginator = new \Zend_Paginator($adapter);
$zend_paginator->setItemCountPerPage(3)
->setCurrentPageNumber($this->_getParam('page'));
$this->view->ticketPaginator = $zend_paginator;
}
added this to the view:-
<div>
<div id="ticket-history">
<?php
echo $this->render('profile/view.ajax.phtml');
?>
</div>
</div>
<script>
$(document).ready(function() {
$('.pagination-control').find('a').live('click', function(e) {
var link = $(this);
$('#ticket-history').load(link.attr('href'), { format: 'html' });
return false;
});
});
</script>
my 'profile/view.ajax.phtml' script contains:-
<?php
echo '<table border="0" width="100%" cellspacing="3" cellpadding="3"><tr>';
foreach($this->ticketPaginator as $ticket){
echo '<td>' . $ticket->getSubject() . '</td>';
}
echo '</tr></table>';
?>
<?php
echo $this->paginationControl($this->ticketPaginator);
?>
This all works fine, however, how would one go about adding a second or third paginator to this view for a different doctrine entity?
Any help would be much apprieciated.
Thanks
Andrew
for that you have to use multiple addActionContext in init()
$this->_helper->ajaxContext->addActionContext('view', 'html')->initContext();
$this->_helper->ajaxContext->addActionContext('list', 'html')->initContext();
and you can continue
add action in controller as listAction() for paginator create file as list.ajax.phtml also and add required code inside them
This problem can be resolved if you manipulate the pagination links to let it call the other action.
For example: In the View Part, you can use the fourth parameter of the paginationControl method to define the links which refers to another action. This link should then be called in pagination_control.phtml.
I am using Kohana 3.2 and I am having problems calling the ouput of a controller in another controller.
What I want...
In some pages I have got a menu, and in others I don't. I want to use make use of the flexability of the HMVC request system. In the controller of a page I want to call another controller which is responsible for the creation of the menu.
What I have a the moment:
file menu.php:
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Menu extends Controller
{
private $_model = null;
public function __construct(Request $request, Response $response)
{
parent::__construct($request, $response);
$this->_model = Model::factory('menu');
}
public function action_getMenu()
{
$content = array();
$content['menuItems'] = $this->_model->getMenuItems();
// Render and output.
$this->request->response = View::factory('blocks/menu', $content);
//echo '<pre>'; print_r($this->request->response->render()); echo '</pre>'; die();
}
}
somepage.php
public function action_index()
{
$this->template->title = 'someTitle';;
$contentData['pageTitle'] = 'someTitle';
$contentData['contentData'] = 'someData';
#include the menu
$menuBlock = Request::factory('menu/getMenu')->execute();
$menuData = array('menu' => $menuBlock);
$this->template->menu = View::factory('pages/menu')->set('menu',$menuData);
$this->template->content = View::factory('pages/somePage', $contentData);
$view = $this->response->body($this->template);
$this->response->body($view);
}
If I uncomment the following line in menu.php, I see the menu rendered:
//echo '<pre>'; print_r($this->request->response->render()); echo '</pre>'; die();
So I guess that part is alright. The problem is in the following line in somepage.php:
$menuBlock = Request::factory('menu/getMenu')->execute();
This gives me back a response object. Whatever I do, I do not get the output in $this->template->menu.
$this->template->menu = View::factory('pages/menu')->set('menu',$menuData);
What must I do to have $this->template->menu contain the view, so I can use it correctly?
I hope this all makes sense. This is the way I would like to do it, but maybe I am completely on the wrong track.
I would do it this way:
class Controller_Menu extends Controller
{
public function action_build()
{
// Load the menu view.
$view = View::factory('navigation/menu');
// Return view as response-
$this->response->body($view->render());
}
}
In your controller get the menu as follows:
// Make request and get response body.
$menu = Request::factory('menu/build')->execute()->body();
// e.g. assign menu to template sidebar.
$this->template->sidebar = Request:.factory('menu/build')->execute()->body();
I would not use the __construct method in your controllers. Use before() instead, this is sufficient for most of the problems (for example auth):
public function before()
{
// Call aprent before, must be done here.
parent::before();
// e.g. heck whether user is logged in.
if ( !Auth::instance()->logged_in() )
{
//Redirect if not logged in or something like this.
}
}
I found the answer to my problem in less than an hour after asking.
I just forgot to put it here.
In somePage.php change :
$menuBlock = Request::factory('menu/getMenu')->execute();
$menuData = array('menu' => $menuBlock);
$this->template->menu = View::factory('pages/menu')->set('menu',$menuData);
To:
$this->template->menu = Request::factory('menu/getMenuBlock')->execute()->body();
And in menu.php change:
$this->request->response = View::factory('blocks/menu', $content);
To:
$request = View::factory('blocks/menu', $content);
$this->response->body($request);
I hope this will help someone else.
I have a problem with displaying a view. When I pass var to view, view doesn't render.
Controller:
public function indexAction()
{
$branchModel = new Application_Model_Branches();
$branches = $branchModel->getAllBranches();
$this->view->menu = $branches;
}
View (index.phtml):
<h2>Menu</h2>
<?php
$this->htmlList($this->menu);
?>
When I try debug $branches without assign it to view, all seems to be ok, but when I try push it to view,index.phtml don't appear.
Regards
You're just missing an echo in your code, the htmlList view helper returns a value - it doesn't echo it. Some examples of the various form view helpers can be seen here
<h2>Menu</h2>
<?php
echo $this->htmlList($this->menu);
?>
controller
$this->view->variableName = "Hello World!";//assign here
$this->view->assign('variableName1', "Hello new World!");//assign here
view
echo $this->variableName;//echo here
echo $this->variableName1;//echo here