Forums / Setup & design / using texttoimage in stylesheet

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 :(

eZ debug

Timing: Jan 31 2025 05:58:28
Script start
Timing: Jan 31 2025 05:58:28
Module start 'content'
Timing: Jan 31 2025 05:58:28
Module end 'content'
Timing: Jan 31 2025 05:58:28
Script end

Main resources:

Total runtime0.2536 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0074 587.9453180.8359
Module start 'content' 0.00740.0095 768.781397.8828
Module end 'content' 0.01690.2366 866.6641526.5547
Script end 0.2535  1,393.2188 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00411.6328200.0002
Check MTime0.00130.4963200.0001
Mysql Total
Database connection0.00070.291010.0007
Mysqli_queries0.197377.79891410.0014
Looping result0.00110.44361390.0000
Template Total0.236393.210.2363
Template load0.00070.283210.0007
Template processing0.235692.904210.2356
Override
Cache load0.00050.196810.0005
Sytem overhead
Fetch class attribute can translate value0.00050.196010.0005
XML
Image XML parsing0.00030.116710.0003
General
dbfile0.01335.2638200.0007
String conversion0.00000.003230.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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