Yii page not redirect - redirect

I have 2 forms
$form=$this->beginWidget('CActiveForm', array(
'id'=>'step1-form',
'enableClientValidation'=>false,
'enableAjaxValidation'=>true,
'clientOptions'=>array(
'validateOnSubmit'=>true,
'validateOnChange'=>false,
),
in Controller
if(isset($_POST['yt0']))
{
Yii::app()->request->cookies['step'] = new CHttpCookie('step', '1');
$this->redirect(Yii::app()->createUrl("timeshares/edit"));
}
in GET i have html code new page but in screen i have old page
pic http://rghost.ru/46015416.view

Try this:
$this->redirect(array('timeshares/edit'));
But I was wondering, edit might need ID. If yes, then try this:
$this->redirect(array('timeshares/edit','id'=>$user));

if(isset($_POST['model_name']))
{
Yii::app()->request->cookies['step'] = new CHttpCookie('step', '1');
$this->redirect(Yii::app()->createUrl("timeshares/edit"));
}
Instead model_name insert your model name. if your model name is yt0 then is correct.

Related

How can I remove or hide Global Links from login screen in SugarCRM?

I am using SugarCRM 6.5 community edition. There are "globalLinks" on Login screen.
I don't want these links Employees, Support, About on login page. How can i remove it from login page only?
I have found solution for remove global links from header. Try with below code:
Create new file custom/Extension/application/Ext/GlobalLinks/links.php
if (isset($global_control_links['training']))
{
unset($global_control_links['training']);
}
if (isset($global_control_links['employees']))
{
unset($global_control_links['employees']);
}
if (isset($global_control_links['about']))
{
unset($global_control_links['about']);
}
Place this in custom/include/globalControlLinks.php:
// To add new links
$global_control_links['training'] = array(
'linkinfo' => array($app_strings['LBL_TRAINING'] => 'index.php?module=Administration&action=ServiceCase'),
'submenu' => ''
);
// To remove existing links
$global_control_links['about'] = array();`

Magento2 custom price render on product page

How to format the product view page price differently from the one from category page ( and possible others ) ?
If I change in my child theme the:
app/design/frontend/VENDOR/my_theme/Magento_Catalog/templates/product/price/final_price.phtml
The price is being changed on both pages (category and product);
I have tried several approaches but it seems that this price rendering mechanism is complicated as hell in Magento2.
Thanks!
<?php
try {
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$request = $objectManager->get(‘Magento\Framework\App\Action\Context’)->getRequest();
$currentPageXML = $request->getFullActionName();
echo $currentPageXML; //catalog_product_view is product detail page controller action
} catch (Exception $e) {}
?>
The above code will help you get the current area of the environment being accessed, and then you can apply a logic
if ($currentPageXML=="catalog_product_view") {
// render my custom need
} else {
// keep the actual code intact.
}
You are facing a problem because same phtml file is being used by both the catalog and product page, so a change in this file will be reflected everywhere.
I hope this will help you.

How to disable layout and view renderer in ZF2?

How can i disable layout and view renderer in Zend Framework 2.x? I read documentation and can't get any answers looking in google i found answer to Zend 1.x and it's
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout->disableLayout();
But it's not working any more in Zend Framework 2.x. I need to disable both view renderer and layout for Ajax requests.
Any help would be great.
Just use setTerminal(true) in your controller to disable layout.
This behaviour documented here: Zend View Quick Start :: Dealing With Layouts
Example:
<?php
namespace YourApp\Controller;
use Zend\View\Model\ViewModel;
class FooController extends AbstractActionController
{
public function fooAction()
{
$viewModel = new ViewModel();
$viewModel->setVariables(array('key' => 'value'))
->setTerminal(true);
return $viewModel;
}
}
If you want to send JSON response instead of rendering a .phtml file, try to use JsonRenderer:
Add this line to the top of the class:
use Zend\View\Model\JsonModel;
and here an action example which returns JSON:
public function jsonAction()
{
$data = ['Foo' => 'Bar', 'Baz' => 'Test'];
return new JsonModel($data);
}
EDIT:
Don't forget to add ViewJsonStrategy to your module.config.php file to allow controllers to return JSON. Thanks #Remi!
'view_manager' => [
'strategies' => [
'ViewJsonStrategy'
],
],
You can add this to the end of your action:
return $this->getResponse();
Slightly more info on the above answer... I use this often when outputting different types of files dynamically: json, xml, pdf, etc... This is the example of outputting an XML file.
// In the controller
$r = $this->getResponse();
$r->setContent(file_get_contents($filePath)); //
$r->getHeaders()->addHeaders(
array('Content-Type'=>'application/xml; charset=utf-8'));
return $r;
The view is not rendered, and only the specified content and headers are sent.

adding Zend_Form_Element_Captcha to form causes form to not display

I am having trouble getting a captcha element to display in a signup form. It was working previously, but now for some reason when I try to add the captcha element to the form the entire form does not display.
Below is the function in my controller file to create the form
private function getSignupForm()
{
// create form
$form = new Zend_Form();
$form->setAction('success');
$form->setMethod('post');
$form->setAttrib('sitename', 'loudbite');
// add elements
require "form/elements.php";
$loudbiteElements = new Elements();
// create username field
$form->addElement($loudbiteElements->getUsernameTextField());
// create email field
$form->addElement($loudbiteElements->getEmailTextField());
// create password field
$form->addElement($loudbiteElements->getPasswordTextField());
// add captcha
$form->addElement($loudbiteElements->getCaptcha());
// create submit button
$form->addElement('submit', 'submit');
$submitElement = $form->getElement('submit');
$submitElement->setLabel('Create My Account!');
return $form;
}
and here is the action to pass the form to the corresponding view
public function newAction()
{
// get the form
$form = $this->getSignupForm();
// add the form to the view
$this->view->form = $form;
}
If I comment out the line in my getSignupForm() function where I add the captcha to the form then the form will display ok minus the captcha element. This leads me to assume that there is a problem with the captcha contruction.
Below is the function in an external model file where the captcha is constructed
public function getCaptcha()
{
$captchaElement = new Zend_Form_Element_Captcha(
'signup',
array('captcha' => array(
'captcha' => 'Figlet',
'wordLen' => 6,
'timeout' => 600))
);
$captchaElement->setLabel('Please type in the words below to continue:');
return $captchaElement;
}
All the other form elements are created in this external model file. Based on the fact that the other elements display correctly if I do not add the captcha element, I assume it is not a problem with accessing the model file.
The last time I used this signup form everything was working ok! And I don't remember having changed anything between then and now.
Any help is greatly appreciated.
Regards
Roan

Zend_Navigation: Having trouble getting breadcrumbs to render using multiple containers [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Zend Framework - multiplate navigation blocks
I'm trying to make breadcrumbs render in my application ( they don't show up anywhere, not even the homepage, which has a corresponding Zend Page Uri object ), which has multiple navigation areas - primary and utility. For the menu generation, I have a MenuController which I render with from within the layout using:
$this->layout()->utility = $this->action('render', 'menu', null, array('menu' => $this->utilityId));
$this->layout()->nav = $this->action('render', 'menu', null, array('menu' => $this->mainMenuId));
The utilityId and mainMenuId properties are numbers, grabbed from a database.
The Menu controller's render method just builds an array and creates a Zend Navigation object, then invokes setContainer and sets it to that container. This is pseudo code because it's rather long:
// MenuController.php
private function renderAction() {
$itemArray[] = array('label' => $label, 'uri' => $uri ); // in a loop
$container = new Zend_Navigation($itemArray);
if ( $container instanceof Zend_Navigation_Container ) {
$this->view->navigation()->setContainer( $container );
$uri = $this->_request->getPathInfo();
$item = $this->view->navigation()->findByUri($uri);
$item->active = true;
}
}
So this render method is called twice from within the layout for the utility and nav.
EDIT:
I think the issue is that I need to specify the $container so my code would be
$this->navigation($container)->breadcrumbs();
However because I'm using $this->action('render', 'menu' ) the $container variable is set there and not returned, is there a way I can specify the container some other way? Possibly using $this->layout()->nav and a property in that which points to the container.
This looks like it's the same issue and someone suggests setting/getting them with Zend_Registry, perhaps I'll try this out.
I suspect you don't have a navigational hierarchy. You need pages within pages.
e.g.
Home Page
[pages] => Sign In
[pages] => Forgot Password
=> Create Account
[pages] => Confirm Account Email
=> Email Confirmed
With the above, breadcrumbs will be rendered on all active pages except for the Home Page... all pages if you do this:
$this->navigation()->breadcrumbs()->setMinDepth(0); // don't skip the root page
Or maybe it's something else, but it's hard to say. I hope that helps, though!
This is probably a dirty solution, but I manually set the container reference using Zend_Registry like so:
Zend_Registry::set( 'nav' . $menu, $container );
And spit it out like so:
$main = Zend_Registry::get( 'nav' . $this->mainMenuId );
echo $this->navigation( $main )->breadcrumbs()->setMinDepth(0);