J!1.5 M-V-C - view.html... How to pass a variable back to a function in a model?
Posted: Mon Jan 14, 2008 3:30 pm
				
				Hi.  I'm trying to work my way through this M-V-C thing..
Basically, I've got a variable in com_mycomponent/views/mycomponent/tmpl/default.php
Which looks like this:
  
It returns the filename of a document from an Indexing Server Catalog object. And it works.
I want to pass $file back to a function in com_mycomponent/models/mycomponent.php
here's my function:
I know I can echo $this->docname; in default.php thus calling the function getDOCmanDocName via view.html e.g. in view.html:
But how do I pass back $file to the function?  I've tried: $this->docname($file) - but don't know if this is valid, and if it is, how do I edit view.html? 
Would appreciate thoughts anyone.. thanks
chris
			Basically, I've got a variable in com_mycomponent/views/mycomponent/tmpl/default.php
Which looks like this:
Code: Select all
$file = $fileRS->fields['filename']->value; It returns the filename of a document from an Indexing Server Catalog object. And it works.
I want to pass $file back to a function in com_mycomponent/models/mycomponent.php
here's my function:
Code: Select all
function getDOCmanDocName($file)
    {
      $db =& JFactory::getDBO();
      $query = 'SELECT dmname AS text'
            . ' FROM #__docman'
            . ' WHERE dmfilename = ' . $file;
      $db->setQuery( $query );
      $docname = $db->loadResult();
      return $docname;
    }
Code: Select all
$model =& $this->getModel();
$docname = $model->getDOCmanDocName();
$this->assignRef('docname', $docname);Would appreciate thoughts anyone.. thanks
chris
 I got my head all twisted.
 I got my head all twisted.