Skip to content

Instantly share code, notes, and snippets.

@drmmr763
Created February 5, 2013 00:48
Show Gist options
  • Save drmmr763/4711170 to your computer and use it in GitHub Desktop.
Save drmmr763/4711170 to your computer and use it in GitHub Desktop.
sample code from an MVC joomla component
<?php
/* Model Code */
class ComponentModelView extends JModelLegacy
{
public function getItem()
{
$id = JFactory::getApplication()->input->getInt('cid');
$row = JTable::getInstance('chapter', 'RootflickTable');
$row->load($id);
$nowDate = JFactory::getDate();
if($nowDate < $row->sub_up)
{
$row->sub_start_days_remaining = date('j', strtotime($row->sub_up) - strtotime($nowDate));
// sets up the remaining time as a php variable
}
return $row;
}
}
/* viewname.php */
/* js area to change the time client-side */
<script type="javascript">
// js code I haven't written yet but I can use: <?php echo $this->item->sub_start_days_remaining; ?> to give it values later
$('time').updateTimeWithThisFunction();
</script>
<?php if ($this->item->sub_start_days_remaining): ?>
<h5>
<div class="time"></div>
</h5>
<?php endif;?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment