I've tried searching for how to include a CSS file directly into the template, but none of the answers are very good. I do not want to include the CSS file using <link>, I want to include it directly into the template. I also do not want to read the entire file into a variable and output the variable in the template.
I tried doing it like this
<style>{include "$ROOT_DIR/public/css/all.css}</style>
but then Smarty tries to parse it as a template, which obviously won't work because of the { and } in the CSS file.
I can't put {literal} ... {/literal} around the include, because then Smarty will just output the include command literally. And obviously I don't want to put the {literal} ... {/literal} in the CSS file, since it's not CSS.
I could read the file into a variable and output that in the template, but that seems like a very backwards way of doing things, and probably not very efficient.
Surely, there must be some way to include a file without parsing it as a template?!
Related
Is there a way, either in YAML or within an R script/Rmd, to turn on the fenced_divs pandoc extension?
If possible, I would prefer being able to turn on fenced_divs without having to specify it inside each individual output format in the YAML block but rather once, globally.
The reason is that I want to have within-document links to items that are not headers using the same code for .docx and .html.
Thanks.
I want to have a template variable pre-processed in a markdown doc.
I tried converting the filename to file.html.md.eco but it just comes out as plain text - ie the markdown plugin doesn't seem to get applied.
The file just as html.md renders fine.
Is it needed to add the plugins to the docpad.coffee to make sure they're applied when using multiple passes?
the FAQ states how to use multiple processors
http://docpad.org/docs/faq
... Alternatively, we can get pretty inventive and do something like this: .html.md.eco which means process this with Eco, then Markdown and finally render it as HTML.
I am using Codeigniter and everything works just fine. I can assign PHP variable to smarty an display them.
But now I am calling a webservice and this webservice returns a complete HTML (and javascript) page.
I want to display this in a smarty template.
So I have done the following:
I have assigned the output of the webservice to a PHP variable and assigned this to a smarty variable (HTMLstring), like I always do. That part works.
In my smarty template I don't need anything but to display the contents of the variable. So my template contains just one line:
{HTMLstring}
But this displays the literal HTML including tags and all. I want to display the output.
(If I copy-paste the output in a separate html file, and open that, it just looks fine)
I 'figured out' the answer.
It appears it makes a difference if I call the template from code or just type the complete url in my browser for testing purposes. The latter didn't work, the former does. I still don't know why. Sorry...
Question closed.
I just want to add some 'default text' to the fields...
My efforts to edit the PHP have not worked at all !!
I'm guessing that the file to edit is the ' mod_simpleemailform.php '
I cant seem to find the "echo's" that spit out the form...
Am i on the right track...?
Thanks!!
Based on my research this is not a module that comes installed with Joomla! I will answer your question when it comes to properly formated modules.
To find your form go into the folder for your module. In your case it should be /modules/mod_simpleemailform.
This is where the "System" for your module resides. You will find files such as:
mod_simpleemailform.xml This is a configuration file for the module.
index.html This prevents the listing of your module's folder contents.
helper.php This is where your module's functions and brains are located.
mod_simpleemailform.php This calls functions in your helper.php in order to get content and information. Once it has all of its data it will call a template file for the module located in /tmpl of your module's directory.
In here you will find:
index.html It does the same thing as the previous index.html
default.php This is your default template file for your module. This file will contain your form and HTML code that you see on screen.
The default.php is the file that you likely want to use. It is possible that your form is in an other file located in the /tmpl folder so you may have to pick around a little bit.
Usually your fields are not in an echo they are just place on the outside of php tags. You will likely want to add a value attribute and then add some text to it like so <input type="text" name="myField" value="My Default Text" />.
Even better still you could add parameters to the XML file so then you may echo a default text you entered in the back-end of Joomla!.
Just follow on Jonathan's answer, yes, you can find the brain of the module inside of helper.phpand all that you need to achieve your goal: "add some 'default text' to the fields".
Inside the constructor function, you can find the following sentence, that save in $l the name of the current field (because it's inside a loop):
$l = trim($params->get($labelLabel));
you can just add a string with your desired default text (i.e. inside a variable: $myDefaultText):
$l = $myDefaultText . trim($params->get($labelLabel));
Is there any way to fetch the raw contents of a CSS file?
Lets imagine that I wanted to fetch any vendor-specific css properties from a CSS file. I would need to somehow grab the CSS contents and parse them accordingly. Or I could just use the DOM to access the rules of a CSS file.
The problem is that in while using the DOM, mostly all browsers (except for <= IE8) tend to strip out all of the custom properties that do not relate to their browser engine (webkit strips out -moz and -o and -ms). Therefore it wouldn't be possible to fetch the CSS contents.
If I were to use AJAX to fetch the contents of the CSS file, then if that CSS file hosted on another domain, then the same origin policy would break and the CSS contents could not be fetched.
If one were to use a cross-domain AJAX approach then there would only be a JSONP solution which wouldn't work since we're not parsing any javascript code (therefore there is no callback).
Is there any other way to fetch the contents?
If a CSS file is on the same domain as the page you're running the script on, you can just use AJAX to pull in the CSS file:
$.get("/path/to/the.css", function(data) {/* ... */});
If not, you could try using Yahoo! Pipes as a proxy and get the CSS with JSONp.
As for parsing, you can check out Sizzle to parse the selectors. You could also use the CSS grammar (posted in the CSS standards) to use a JS lex/yacc parser to parse out the document. I'll leave you to get creative with that.
Good luck!
No, you've pretty much covered it. Browsers other than IE strip out unknown rules from their object models both in the style/currentStyle objects and in the document.styleSheets interface. (It's usually IE6-7 whose CSS you want to patch up, of course.)
If you wanted to suck a stylesheet from an external domain you would need proxy-assisted-AJAX. And parsing CSS from would be a big nasty job, especially if you needed to replicate browser quirks. I would strenuously avoid any such thing!
JSONP is still a valid solution, though it would hurt the eyes somewhat. Basically, in addition to the callback padding, you would have to add one JSON property "padding" and pass the CSS as a value. For example, a call to a script, http://myserver.com/file2jsonp/?jsonp=myCallback&textwrapper=cssContents could return this:
myCallback("cssContents":"body{text-decoration:blink;}\nb{text-size:10em;}");
You'd have to text-encode all line breaks and wrap the contents of the CSS file in quotes (after encoding any existing quotes). I had to resort to doing this with a Twitter XML feed. It felt like such a horrible idea when I built it, but it did its job.