1

IM building a component and im trying to work out how to do this

Bookings / Orders / Order

I have a bookings view and form I have a orders view and form

However...

Im having trouble getting bookings to show orders based on booking id. I have added to the models file WHERE bid=GET[bid]

However that messes things up when coming back from editing an order.

The steps are

  • click bookings
  • view orders based on booking id ( my custom hack in the models file for orders )
  • open order
  • edit order
  • click save
  • return to orders view where booking id=booking id

I can manage this by adding a little hack into the controllers order.php file

but...

That works for saving and going back and yet it crashes all other actions like publish,archive etc..

There must be a section in the mvc where i can put the additional &bid=$_GET['bid'] and it works across all submission actions.

What is the correct way to build a component with views that are parent to each other.

Im happy to provide code but theres quite a lot. So maybe if you could direct me first.

some other notes:

here is my link to the orders from the bookings view

JRoute::_('index.php?option=com_tourbookings&view=orders&bid='.(int) $row->id)

Here is my hack within the models/orders.php

$query->where('a.bid = '.$_GET['bid']);

So far that works good, if i click it ill get the orders based on bid.

Then i am lost. Because if i try to hack from here i am completely stuck as it wont come back to the orders based on bid without crashing.

If i hack the controllers/order.php ( which has changed again in joomla 3.3+ )

I find that it kind of works and allows me to go back to the previous page with bid=bid attached but if i try to archive,unpublish or do anything of that sort im stuck.

Cheers John

1
  • First of all - never ever do like this $query->where('a.bid = '.$_GET['bid']); because you will be hacked. It is called SQL Injection. Second - I do not understand why there is a problem when all other actions does not work. What exactly is wrong? Commented Oct 30, 2014 at 12:39

1 Answer 1

2

The question is very general. At first glance:

  • The question depends on how you are implementing a MVC in Joomla! and which Controller flavour are you following. In my perspective, I avoid any MVC issue just relaying on FoF, instead of elucidating how to implement a native controller in Joomla 2.5, 3, or 3.x.
  • DO NOT use $_GET, for security reasons. Instead of using the raw variables, implement JInput. For example, FoF implements F0FInput, extending JInput.
5
  • Hi, yes youre right. Its definatley a steep learning curve. I have decided to take a more simplistic approach. IT would be so much better if i could undertsand how the relationships work between data. It seems that when bulding a component there is only - list view and edit or form view - what if you wanted list view based on dates / list view of all those dates / edit or form view of that item
    – Jonnypixel
    Commented Nov 3, 2014 at 2:41
  • 1
    Yes, this is the common Joomla MVC. If you want to add a new subview parameter you can do it. For instance, in FoF you have layout or type (e.g. json) parameters, they are used to load different "subviews" in the same view/tmpl directory.
    – Anibal
    Commented Nov 3, 2014 at 20:35
  • Oh cool, im going to look now. I really want to understand this. If i can get my head around it would be really powerful for building more hardcore components.
    – Jonnypixel
    Commented Nov 4, 2014 at 0:37
  • i just looked at the FOF page. Over my head. Any way of pointing me to a page the has a tutorial on creating a sub-view and using the FoF - please.
    – Jonnypixel
    Commented Nov 4, 2014 at 0:41
  • Sure, please check this chapter: Chapter 2. Component overview and reference - akeebabackup.com/documentation/fof/fofview.html#id510150
    – Anibal
    Commented Nov 4, 2014 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.