Welcome, Guest
Username: Password: Remember me

TOPIC: Single FE Layout Form then what?

Single FE Layout Form then what? 20 Mar 2012 01:39 #1673

  • edwardcox
  • edwardcox's Avatar
  • Offline
  • Premium Member
  • Here to help.
  • Posts: 131
  • Thank you received: 26
  • Karma: 12
Hi All, sorry about the obtuse Subject, here's what I mean.

With my Project I have a Single Table, and a Single Front End layout Item Form. I can display this form (to capture Quotation information) on front end of my site, but then how can I make that Form re-direct to somewhere else in my site (i.e. another page/Article, Menu)? Is this possible?

An example:
User visits site.
User Clicks on Menu Item to Request Quotation.
Quotation FrontEnd Layout Form is show.
User fills in Quotation FronEnd Layout Form and clicks 'Save'
Rather than the same form being shown again, they should be redirected to a 'Thank You' page/Article.

Any suggestions please?

Thanks,

Edward.
Passionate Joomla! Developer and J-Cook pro evangelist.
www.jcombuilder.com - we build great Joomla!® Components so you don't have to.
The administrator has disabled public write access.

Re: Single FE Layout Form then what? 20 Mar 2012 06:27 #1675

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Cook cannot do this natively.


TODO :
Create your redirection in the controller, after the task execution.
JRequest::setVar('option', 'com_content');
...
...
JRequest::setVar('cid', #Article ID#);
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: edwardcox

Re: Single FE Layout Form then what? 20 Mar 2012 11:08 #1682

  • edwardcox
  • edwardcox's Avatar
  • Offline
  • Premium Member
  • Here to help.
  • Posts: 131
  • Thank you received: 26
  • Karma: 12
Thanks Jocelyn,

Nearly there... now I am redirected to a non existent article:
http://maelstrom/index.php/component/content/?view=quotation&Itemid=155&lang=&cid[0]=42

I have created an Article and a Category ready for the redirection. Article: 42, Category: 19

And here is the section of code modified in the controller: quotations.php
if ($cid = parent::_save($post))
		{
			$vars = array();
			$layout = JRequest::getVar( 'layout');
			switch($layout)
			{
				case 'quotation':
					JRequest::setVar( 'view'  , 'quotation');
					JRequest::setVar( 'layout', 'quotation' );
					JRequest::setVar('option', 'com_content');
					JRequest::setVar('cid', 42);
					break;


				default:
					JRequest::setVar( 'view'  , 'quotation');
					JRequest::setVar( 'layout', 'quotation' );
					JRequest::setVar('option', 'com_content');
					JRequest::setVar('cid', 42);
					// JRequest::setVar( 'cid', null );
					break;

			}

			$this->setRedirect(QuotepleaseHelper::urlRequest($vars));
		}
		else
			//Keep the post and stay on page
			parent::display();

	}

Have I missed something obvious?

Thank you,

Edward.
Passionate Joomla! Developer and J-Cook pro evangelist.
www.jcombuilder.com - we build great Joomla!® Components so you don't have to.
Last Edit: 20 Mar 2012 11:09 by edwardcox. Reason: typo
The administrator has disabled public write access.

Re: Single FE Layout Form then what? 20 Mar 2012 11:15 #1683

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Your link :Doesn't work



I think, you should remove the "view=quotation"
//JRequest::setVar( 'view'  , 'quotation');
//JRequest::setVar( 'layout', 'quotation' );

And for some amelioration :
JRequest::setVar('cid', 42);

Put your 42 value in a component parameter (in case you want to change the article)
Coding is now a piece of cake
The administrator has disabled public write access.

Re: Single FE Layout Form then what? 20 Mar 2012 11:37 #1685

  • edwardcox
  • edwardcox's Avatar
  • Offline
  • Premium Member
  • Here to help.
  • Posts: 131
  • Thank you received: 26
  • Karma: 12
Sorry, still no luck.

The site is on my Localhost under MAMP that's why it isn't visible. Sorry.

So, here's what I have now:
if ($cid = parent::_save($post))
		{
			$vars = array();
			$layout = JRequest::getVar( 'layout');
			switch($layout)
			{
				case 'quotation':
					// JRequest::setVar( 'view'  , 'quotation');
					// JRequest::setVar( 'layout', 'quotation' );
					JRequest::setVar('option', 'com_content');
					JRequest::setVar('cid', 42);
					break;


				default:
					// JRequest::setVar( 'view'  , 'quotation');
					// JRequest::setVar( 'layout', 'quotation' );
					JRequest::setVar('option', 'com_content');
					JRequest::setVar('cid', 42);
					// JRequest::setVar( 'cid', null );
					break;

			}

			$this->setRedirect(QuotepleaseHelper::urlRequest($vars));
		}
		else
			//Keep the post and stay on page
			parent::display();

Note that the changes were made, but still are incorrect redirect:
500 - View not found [name, type, prefix]: quotation, html, contentView
http://maelstrom/index.php/component/content/?view=quotation&Itemid=155&lang=&cid[0]=42

And although I would love to have the Article ID to be changed by putting it into a Parameter of the Component, I have no idea where to start.. XML file?

Thanks for being patient with me,

Edward.
Passionate Joomla! Developer and J-Cook pro evangelist.
www.jcombuilder.com - we build great Joomla!® Components so you don't have to.
The administrator has disabled public write access.

Re: Single FE Layout Form then what? 20 Mar 2012 12:00 #1687

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Oh yes, of course.
I forgot...
JRequest::setVar( 'view'  , null);
JRequest::setVar( 'layout', null );
Coding is now a piece of cake
The administrator has disabled public write access.

Re: Single FE Layout Form then what? 20 Mar 2012 13:02 #1690

  • edwardcox
  • edwardcox's Avatar
  • Offline
  • Premium Member
  • Here to help.
  • Posts: 131
  • Thank you received: 26
  • Karma: 12
Sorry, please don't hate me ;-)

Still no winner.

The page that calls the quotation is : http://maelstrom/j-stuff/quotation
Even after the change as suggested it goes to:
http://maelstrom/component/content/?view=&layout=&Itemid=155&lang=&cid[0]=42

So, is the cid[0]=42 the pointer to the article? What is the 'Itemid' (155?)? And why would the path still reference the Component? And the null layout is ok?

This is where the redirect should end up (after now enabling .htaccess):
http://maelstrom/j-stuff/thanks-page

The Article is there as I linked a Menu Item to it successfully.

Help?!?.. thank you,

Edward.
Passionate Joomla! Developer and J-Cook pro evangelist.
www.jcombuilder.com - we build great Joomla!® Components so you don't have to.
Last Edit: 20 Mar 2012 13:12 by edwardcox. Reason: Additional info
The administrator has disabled public write access.

Re: Single FE Layout Form then what? 20 Mar 2012 13:22 #1691

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
It is my fault, because I didn't tried.
I am now starting a travel to go to the Joomla day, and I answered too fast.

ItemId is relative to the current menu item. (only a follower)
'Component' is ok



Try this :
JRequest::setVar( 'view'  , 'article');
JRequest::setVar( 'layout', null );
JRequest::setVar( 'cid'  , null);
JRequest::setVar( 'id', 42 );

Because in the article component, 'cid' is 'id'

It creates a non very clean url, because the url recomposer should not instanciate vars if they are null.
(Something to fix there)


And if it don't work, try this :
$this->setRedirect(JRoute::_('index.php?option=com_content&view=article&id=1', false));
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.109 seconds

Get Started