Created
February 5, 2013 00:48
-
-
Save drmmr763/4711170 to your computer and use it in GitHub Desktop.
sample code from an MVC joomla component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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