using texttoimage in stylesheet

Author Message

Alberto Perni

Saturday 19 November 2005 12:59:46 pm

Hi there!

Is there any way to use texttoimage within a css style? Be it within an external .css or within a template. I've been searching for any similar case but so far I haven't found anything :(

I'm using xhtml & css to build a site, so I basically want to 'substitute' text headers for images (using css). This way my xhtml is keeped clean, without these headers as img tags, but with simple <h[1-6]> tags overridden by a background-image for instance.

Example:

<h3>title</h3>

and in the css:

#h3 {
background: url("GENERATED_USING_TEXT_TO_IMAGE");
}

Thanks in advance!

Roy Bøhmer

Saturday 19 November 2005 2:46:20 pm

I'm on really thin ice here, but I think it should be possible. But you have to write the css-statement directly in the template - not in an external .css-file.

The styles have to be surrounded by {literal}{/literal} so the curly brackets wont be interpreted by ez-template engine.

<style>
{literal}
h3 { 
{/literal}
{"Your text"|texttoimage('h3')}
{literal}
}
{/literal}
</style>

I've not tried the above code. Hope you'll work it out!

Roy

Alberto Perni

Saturday 19 November 2005 3:04:11 pm

Thanks for you reply Roy! :)

Alas, AFAIK, that would create an <img> tag within the css statement.

I guess I'm looking for something that could generate the texttoimage image, and return me a string containing the url to it, instead of dynamically writing the html code.

Any help on this?

Roy Bøhmer

Saturday 19 November 2005 3:50:03 pm

Oops... was a little to quick there, I guess.

A little resarch found: design/standard/templates/image/layer.tpl is used as template for the texttoimage. (You should copy the file to your own design...)

But if your using this for other purposes than css I'll guess you have to do some serious overrides or perhaps some if-statements in the template. I've no ides which other functions in ez that relies on the above mentioned template.

Roy

Alberto Perni

Saturday 19 November 2005 6:09:29 pm

Thanks for the tip Roy!

I have succesfully managed to adapt layer.tpl to make it return only the full url to the image generated by texttoimage:

content of layer.tpl:
{$layer.imagepath|ezroot("single")}

The "single" parameter adds single quotes to the url. Handy for applying this to the css statement.

However, as you've mentioned, it has its drawbacks. I've seen that Imagefile() also makes use of this template.

Sorry if this sounds crazy, but is there any way to create an override just for the texttoimage function?

The perfect solution would be a method, function or a parameter to either image() or texttoimage() telling I only want the url of the image. So far I haven't found anything :(

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 06:18:39
Script start
Timing: Jan 19 2025 06:18:39
Module start 'layout'
Timing: Jan 19 2025 06:18:39
Module start 'content'
Timing: Jan 19 2025 06:18:39
Module end 'content'
Timing: Jan 19 2025 06:18:39
Script end

Main resources:

Total runtime0.0154 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 589.1563152.6250
Module start 'layout' 0.00530.0027 741.781339.4609
Module start 'content' 0.00800.0052 781.242293.3359
Module end 'content' 0.01320.0021 874.578134.3047
Script end 0.0153  908.8828 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002415.7915140.0002
Check MTime0.00117.0985140.0001
Mysql Total
Database connection0.00064.063210.0006
Mysqli_queries0.002214.547930.0007
Looping result0.00000.091610.0000
Template Total0.001711.210.0017
Template load0.00095.861110.0009
Template processing0.00085.280410.0008
Override
Cache load0.00064.134610.0006
General
dbfile0.00031.734380.0000
String conversion0.00000.052840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs