Custom component view to menu items in admin area?
-
- Joomla! Intern
- Posts: 54
- Joined: Fri Jan 23, 2009 10:39 pm
Custom component view to menu items in admin area?
How to add Custom component view to menu items in admin area?
I can see there only main component view, and need a link to additional.
-
- Joomla! Intern
- Posts: 54
- Joined: Fri Jan 23, 2009 10:39 pm
Re: Custom component view to menu items in admin area?
the problem is that joomla doesn't allow "_" in the name of view folders, this is view view folders with "_" aren't shown in the menu list.
- Presto-X
- Joomla! Enthusiast
- Posts: 241
- Joined: Fri Apr 06, 2007 12:23 am
- Location: Boise, ID
- Contact:
Re: Custom component view to menu items in admin area?
Hey devlabs,
Open your controller.php file in your component folder
Look for something like this:Then just after that before for Add Now go to your components views folder and add a new folder call it what you want your view to be. Create a new file in here called view.html.php Now create a new folder in your new view folder called tmpl then create a new file called default.php this will hold the code for this view.
Open your controller.php file in your component folder
Look for something like this:
Code: Select all
if(JRequest::getCmd('view') == '') {
JRequest::setVar('view', 'default');
}
Code: Select all
parent::display();
Code: Select all
if(JRequest::getCmd('view') == 'add') {
JRequest::setVar('view', 'YOUR_NEW_VIEW');
}
Code: Select all
// no direct access
defined('_JEXEC') or die('Restricted access');
jimport( 'joomla.application.component.view');
/**
* Change the name of DealerlocatorViewAdd to what you have in your controller for the call class YOUR_CONTROLLER_NAMEController extends JController { and replace Add on the end with your view name
*/
class DealerlocatorViewAdd extends JView {
function display($tpl = null) {
parent::display($tpl);
}
}
- Presto-X
- Joomla! Enthusiast
- Posts: 241
- Joined: Fri Apr 06, 2007 12:23 am
- Location: Boise, ID
- Contact:
Re: Custom component view to menu items in admin area?
PS. I use Joomla Component Creator http://www.notwebdesign.com/joomla-component-creator/ to build the foundation of my components to save time, check it out.
PSS. take a look here for more info on component building: http://docs.joomla.org/Developers#Components
PSS. take a look here for more info on component building: http://docs.joomla.org/Developers#Components
-
- Joomla! Intern
- Posts: 54
- Joined: Fri Jan 23, 2009 10:39 pm
Re: Custom component view to menu items in admin area?
Thanks, but the problem was in the "_" sign in the name of view folder, Irenamed it and everything works fine.
- Presto-X
- Joomla! Enthusiast
- Posts: 241
- Joined: Fri Apr 06, 2007 12:23 am
- Location: Boise, ID
- Contact:
Re: Custom component view to menu items in admin area?
Ahh I misunderstood what you where looking for my bad :O)
-
- Joomla! Fledgling
- Posts: 3
- Joined: Fri Feb 10, 2012 7:27 pm
Re: Custom component view to menu items in admin area?
Hey Presto-X
I was interested in an example you posted on the joomla forum regarding making menu item type appear in the new menu item form.
What I don't understand here is the last part. You create the controller class
what do you mean Add on the end with your view name? The class DealerlocatorAdd extends JView{} is in the view.html.php right? You mean just replace the word "Add" on the end of the View class name? I guess I am just trying to understand consistently in your example what the view name would be so I can understand what parameters are being passed. I am also just trying to understand where each code block resides.
Also this block of code:
What you are saying here is if the request has a view command with a value of add, this is the menu item form submitting a request to create a new menu item with a specific view? Is that understanding correct?
Thank you. ggerstein
I was interested in an example you posted on the joomla forum regarding making menu item type appear in the new menu item form.
Code: Select all
Open your controller.php file in your component folder
Look for something like this:
Code:
if(JRequest::getCmd('view') == '') {
JRequest::setVar('view', 'default');
}
Then just after that before for
Code:
parent::display();
Add
Code:
if(JRequest::getCmd('view') == 'add') {
JRequest::setVar('view', 'YOUR_NEW_VIEW');
}
Now go to your components views folder and add a new folder call it what you want your view to be. Create a new file in here called view.html.php
Code:
// no direct access
defined('_JEXEC') or die('Restricted access');
jimport( 'joomla.application.component.view');
/**
* Change the name of DealerlocatorViewAdd to what you have in your controller for the call class YOUR_CONTROLLER_NAMEController extends JController { and replace Add on the end with your view name
*/
class DealerlocatorViewAdd extends JView {
function display($tpl = null) {
parent::display($tpl);
}
}
Now create a new folder in your new view folder called tmpl then create a new file called default.php this will hold the code for this view.
Code: Select all
YOUR_CONTROLLER_NAMEController extends JController{and replace Add on the end with your view name
*/
class DealerlocatorViewAdd extends JView {
function display($tpl = null) {
parent::display($tpl);
}
}
Also this block of code:
Code: Select all
if(JRequest::getCmd('view') == 'add') {
JRequest::setVar('view', 'YOUR_NEW_VIEW');
}
Thank you. ggerstein