1

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

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

I am not quite understand the logic behind & JFactory::getDocument(); Could you please explain? Thank you!
1

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');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.