Component Coding

For Joomla! 2.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Note: All 1.6, 1.7 and 3.5 releases have reached end of life and should be updated to 3.x.

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Locked
Verdo
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Fri Feb 08, 2013 6:22 pm

Component Coding

Post by Verdo » Wed Mar 13, 2013 8:44 am

Hello all again,

I have successfully built my own custom component from scratch, but I am stuck on a presumably relatively simple problem.

For the purpose of this example lets say that:
A= Home page
B= Player(Multiple) list page
C= Player(Individual) page

I have so far got part A and C working. I can get to my individual player page by entering in their id into the url.
Image

What I am unsure about now is creating a view before this when you click on the players menu button that it directs you to a view which displays a list of all players. I have already created a function within the model which returns all players in the database for the purpose of this view. I can upload my component or paste any of my code into this post if needed.

I did follow http://docs.joomla.org/Developing_a_Mod ... _Component on how to create a component so I presume I have the default settings for my component.

User avatar
bewebdev
Joomla! Ace
Joomla! Ace
Posts: 1017
Joined: Tue Apr 17, 2012 11:28 am
Location: Lincolnshire, UK

Re: Component Coding

Post by bewebdev » Wed Mar 13, 2013 9:38 am

Have you used categories? It might be a more flexible solution later on.

Anyway, as far as I know you should just need create a view, then set the model in the view to the one you need using something like

Code: Select all

$mod = JModel::getInstance('Helloworld', 'HelloworldModel', array());
		$this->setModel($mod, true);
Then you can call the function you created in the model and assign it to a variable, something like

Code: Select all

$this->golfers = $this->get('allGolfersFunction');
then in your tmpl/default.php (or whatever) you should be able to loop through $this->golfers and list them all on the page.

If you run into any more trouble it'll probably be a good idea to post your code to see exactly what you are doing.

regards
@bewebdev ^CB
Joomla & Magento Specialists.
white label web talent
http://www.missingmojo.co.uk

Verdo
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Fri Feb 08, 2013 6:22 pm

Re: Component Coding

Post by Verdo » Wed Mar 13, 2013 8:35 pm

Cool thanks a mil!


Locked

Return to “Joomla! 2.5 Coding”