Reputation: 115
I am add some jquery and css into a joomla component file view/edit/tmpl/default.php. I know I need to use jdoc include, but what is the steps of doing so? Where should I put the jdoc:include?
The code is like this.
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$row = $this->row;
?>
<div class="componentheading" style="margin-bottom:10px;">Edit Event</div>
<form id="form" method="post" action="index.php?option=com_event&view=save" >
<table >
<tr>
<td>Title</td>
<td><input type="text" name="title" value="<?php echo $row->title;?>"></td>
</tr>
<tr>
<td>Start Time</td>
<td><input type="text" name="from" value="<?php echo $row->from;?>" id="datetimepicker"></td>
</tr>
</form>
The files that need to be include
-jquery.datetimepicker.css
-jquery.datetimepicker.js
-jquery.js
Upvotes: 1
Views: 1070
Reputation: 8872
Since jQuery is included with Joomla 3, you can use following code in the view you want to include jQuery in
JHtml::_('jquery.framework');
And for the CSS part, use following traditional method
/**
* Notice only = instead of &=
*
*/
$doc = JFactory::getDocument();
$doc->addStyleSheet(JURI::root(true) . '/your/css/path/here');
or
JHTML::stylesheet('/your/css/URL/here');
Upvotes: 1
Reputation: 22711
Can you try this,
$document =& JFactory::getDocument();
$document->addStyleSheet('your css url here ');// for css
$document->addScript('your jaavscript url here ');// for script
Ref: http://docs.joomla.org/J3.2:Adding_JavaScript_and_CSS_to_the_page
Upvotes: 3