The Joomla! Forum ™



Forum rules


Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
PostPosted: Tue Apr 27, 2010 12:49 pm 
Joomla! Intern
Joomla! Intern

Joined: Fri Jan 23, 2009 10:39 pm
Posts: 54
Image

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.


Top
 Profile  
 
PostPosted: Fri Apr 30, 2010 6:04 pm 
Joomla! Intern
Joomla! Intern

Joined: Fri Jan 23, 2009 10:39 pm
Posts: 54
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.


Top
 Profile  
 
PostPosted: Fri May 07, 2010 4:26 am 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Fri Apr 06, 2007 12:23 am
Posts: 236
Location: Boise, ID
Hey devlabs,

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.


Top
 Profile  
 
PostPosted: Fri May 07, 2010 4:27 am 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Fri Apr 06, 2007 12:23 am
Posts: 236
Location: Boise, ID
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


Top
 Profile  
 
PostPosted: Fri May 07, 2010 8:33 am 
Joomla! Intern
Joomla! Intern

Joined: Fri Jan 23, 2009 10:39 pm
Posts: 54
Thanks, but the problem was in the "_" sign in the name of view folder, Irenamed it and everything works fine.


Top
 Profile  
 
PostPosted: Fri May 07, 2010 9:26 am 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Fri Apr 06, 2007 12:23 am
Posts: 236
Location: Boise, ID
Ahh I misunderstood what you where looking for my bad :O)


Top
 Profile  
 
PostPosted: Fri Feb 10, 2012 7:36 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Fri Feb 10, 2012 7:27 pm
Posts: 3
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.


Code:
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.


What I don't understand here is the last part. You create the controller class
Code:
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);
    }
}

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:

Code:
if(JRequest::getCmd('view') == 'add') {
            JRequest::setVar('view', 'YOUR_NEW_VIEW');
        }


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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 



Who is online

Users browsing this forum: No registered users and 22 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group