How can i use gantry object in chronoform? - joomla2.5

I want to add css and js file in head. But my template is using gantry. So I need to use gantry object to add css and js. But this object is not accessible in my custom form code. I think my requireonce function can not include the file.
require_once('../../../../templates/rt_graffito/lib/gantry/gantry.php');
$gantry->init();
$gantry->addStyle('media/moo_rainbow/css/mooRainbow.css', 5);
$gantry->addScript('media/moo_rainbow/js/mooRainbow.js');
This is the code I am using in my chrono form. But it's not working.

I bet you can use core Joomla document object and gantry shall pick it up, try follow:
<?php
// ... some code here
$document = &JFactory::getDocument();
$document->addScript('media/moo_rainbow/js/mooRainbow.js');
$document->addStyleSheet( 'media/moo_rainbow/css/mooRainbow.css');
// ... other code
and documentation reference
http://docs.joomla.org/JDocument/addStyleSheet
http://docs.joomla.org/Adding_JavaScript

Related

Ember 3.16 Octane - Component not displaying in Application.hbs

I used ember generate to create a header component for a youtube video I am following. I have a few questions -
When I ran ember generate component header, the terminal responded with creating the header.hbs file in app>components, but then skips header.js in app/components. I manually created a header.js file in that directory and if I do an alert() in the js file it works.
I have the following code in my header.hbs file.
<h1>Hello There!</h1>
{{yield}}
In my application.hbs file :
<Header/>
{{outlet}}
thoughts, suggestions? Thank you for any help in advance!
Let me try to explain this a bit. Basically there are 4 kinds of components in ember.
without a .js file:
When you invoke a component ember will first look up the component class. When it does not find such a class the behavior depends on the optional feature template-only-glimmer-components. This is by default enabled for new octane apps.
If it is enabled ember will look up the component template based on some standard rules and use it, but there will be no backing class. That is pretty nice. This is also basically what you get in a octane app when you do ember g component my-component.
When template-only-glimmer-components is disabled then an implicit classic component class will automagically be created and used together with the correct template. You don't want this behavior. If you still have it you can migrate away from it by 1) creating a .js file for every component and then 2) enabling template-only-glimmer-components.
with a .js file
When a js file is found ember will get the default export of that module. Then it will look up the correct component manager. This actually depends on that export: setComponentManager should have been called on it. This is usually done in a base class as #ember/component or #glimmer/component.
But you can also write your own custom component manager.
Basically ember will then also look up the template based on that component. A public API for this is proposed in this RFC, but currently a private API is used for the so called template co-location where you place your .hbs file next to your .js file with the same name and just a different extension. This is the default in octant. Here a ember internal build-step in ember-cli basically adds your template to the .js file and uses that API. You can also see the result in a browser debugger. So when there is no default export then ember can not find your template.

Changing default file upload input

I'd like to add the following attribute to the tag on the django file upload form as part of a progress bar implementation:
onchange="uploadFile()"
Do you know how I would be able to modify the default file upload input with this assignment?
You'll want to add the following to your form: field.widget.attrs["onchange"]="uploadFile()"
And include the javascript somewhere within the template being used.

not able to add custom template files in gitbook themes

I am trying to create a custom gitbook theme and in that I also want to change the layout so that the book I create using the theme have the layout that I want. I copied the default templates dir in my assests dir of the custom theme and then modified the layout.html and header.html files as I wanted. Then to include the modified template files, I added the following attribute to the index.js file
module.exports = {
book: {
assets: "./assests",
templates: {
"layout":"templates/layout.html",
"header":"templates/includes/book/header.html",
},
......
......
However with this configuration, the generated book is not picking the template file changes. However I do see the css/js changes that I had done.
For the record, layout and header template files do exist if you're going the "unadvised" (emphasizing the unadvised nature of this) route of:
Add "theme": "./customtheme" to your book.json file.
Create your customtheme folder in the root with the files from the Gitbook repo
Edit from there
This is so far the only way I've found edit your favicon, sidebar, header, and layout files. It's not recommended because you're no longer using the files in the repo, so updates could break it, but some things either aren't easy or possible to make changes without doing something messy and hacky like this. Hopefully simple things like updating a favicon, header, or sidebar could be made to be easier in the future. I've only found this solution after many, many google searches and plugin comparisons, so maybe some one has a better solution that I haven't found yet.
Templates "layout" and "header" don't exist. You can only change:
site: template for the website
glossary: template for the glossary
langs: template for the choice of languages
page: template for the ebook
Changing templates is really not advised, you should use plugins to only extend html,css,js using: https://github.com/GitbookIO/plugin/blob/master/index.js#L2

How to get HTML from precompiled Ember template?

I have HTML code that I want to load on certain actions. It's a game and the user is able to switch between scenes. It is not possible to change routes for this, but I have to load HTML code for that scene from a template file.
All templates are precompiled with grunt-ember-templates in one JS file. I can access the according function via Ember.TEMPLATES["scene_name"], but it's a function with a lot of parameters - how can I use this? Or should I use "another way"?
Edit:
The pre-compiled template code like this.
Ember.TEMPLATES["scenes/bg1"] = Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {};
data.buffer.push("much HTML code");
});
All I want is the content of the data Object.

Magento programmatically appending code to template pages

I am developing a Magento extension and would like to run some jQuery script in the footer of the html template.
I have manually edited page.xml layout file to load my jQuery source and manually edited the footer.phtml template file to test my code, but I now want to package it up into an extension. The question is how to do this within my extension configuration, to tell magento to load the new jQuery source library in the header, and to append code somewhere in the footer (or anywhere) in the magento generated theme html.
Create a custom Magento Module
Use this module to add a customer Package Layout Update XML File
Use this Package Layout Update XML files to add a javascript src link to a (CDN?) jQuery, and add a custom block to the before_body_end block
Use this custom block to output your needed Javascript code
Use Magento Connect System->Magento Connect->Package Extensions to package up your customer Magento Module file, as well as any other files on the system you used (phtml template, jQuery files if not using a CDN, etc) into an Extension.
Wouldn't it be easier to use a static block? This way the client or yourself could update the jQuery right in the admin area without going into code. You could also add logic with multiple blocks if you needed. You can display a static block in a template like so:
<?php echo $this->getChildHtml('staticblockname') ?>
Otherwise you might want to read this tutorial on creating a module (which you call an extension): http://magento4u.wordpress.com/2009/06/08/create-new-module-helloworld-in-magento/