Hello,

I have a scenario where I'm not sure how to apply Cake conventions.
I'm building a reporting app where the most complex part is the report
templates (views).

My main question is: if I really, *really* want to make a function
call to a controller from a view (even though it is against the
convention), is that possible? RequestAction is proving inadequate as
I need to give more complex arguments than a string.

The main problem is that each template requires a different set of
data which is unknown to the controller, so it has to be pulled from
the view. If you have the time, continue reading, cause I could do
with some advice/opinions on what the best solution for the following
is:

-----

The relevant modules for this part are the reports controller, the
template controller and the various template files. The way the flow
currently works is: the user requests to create a report to the
reports controller. A report type is specified, i.e. "/reports/create/
monthly_update"

The reports controller will then render the template  which is a THTML
file, e.g. monthly_update.thtml. Inside the template file there are
various requestActions which from the templates controller requests
the Items that are relevant. Items are tied to an Artist and have a
type and a status. So a simple template could look like:

<h1>Monthly update...</h1>
<?php
  $items = $this->requestAction("/templates/get_items_this_month/
$artistId/".ITEMTYPE_NEWS.'/'.ITEMSTATUS_CONFIRMED);
?>
<h2>Confirmed news:</h2>
<?php foreach($items as $item): ?>
<p>
  <?php echo $item['Item']['text'] ?>
</p>
<?php endforeach ?>

As a first draft this worked fine, but requestAction quickly becomes
inadequate, as each template wants to display it's specific selection
of types and statuses of items. Calling requestAction is limited as
you can't send complex stuff like arrays as arguments. So is there any
way I can make actual function calls to the template controller
instead?

Or should I be going about this in some other way? Maybe having a
separate file per template specifying what data to request before
rendering the thtml file? Would like to avoid this as I like the idea
of having a standalone template file.

Thanks, and apologies for long post...
Simon


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to