CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> General/Other

 Custom Template question

Print topic Send  topic

Author Message
George L
Posted: 06/16/2004, 4:22 PM

Hi,
I need to have a dynamic height attribute for and image on my Record Form.
My code:
+++htm page++++++++++++++++++++++++++++++++++
<!-- BEGIN pic -->
<td><!-- <img height="{picture_height}" src="/images/parts/{image}"> -->  </td>
<!-- END pic -->

+++php page++++++++++++++++++++++++++++++++++

function frmPicture_BeforeShow()
global $frmPicture;
global $Tpl;
list($w, $h) = getimagesize("images/parts/".$frmPicture->image->GetValue());

$Tpl->SetBlockVar("pic","");
$Tpl->SetVar("picture_height",$h);
$Tpl->Parse("pic",True);

+++++++++++++++++++++++++++++++++++++++++
Image can't be displayed.
The only way I made it work was to put the whole html string inside the variable and delete it from html page: $picture_height= "<img height='".$h."' src='/images/parts/".$frmPicture->image->GetValue()."'>";

In CCS's Help file there is an example for a custom block located inside another block (which I was trying to use) - it uses function Tasks_BeforeShowRow()

in my case I don't have rows - I use a form to display a single record.
I really want to make it work "correctly".
Any ideas on what I'm doing wrong?
Thanks
peterr


Posts: 5971
Posted: 06/16/2004, 8:54 PM

I'd suggest posting questions related to PHP code to the PHP Forum, in case no one responds here.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Sixto Luis Santos
Posted: 06/17/2004, 12:00 AM

Hello there...

You're on the right track, but you need to render {image} manually:

  
$oBlk=$Tpl->block_path; // Save the current path  
$Tpl->block_path=$oBlk."/pic"; // Enter custom block  
$frmPicture->image->Show(); // Force the render  
$Tpl->block_path=$oBlk; // Reset the path  
$Tpl->SetBlockVar("pic",""); // This can be removed. Not doing anything  
anyway.  
$Tpl->SetVar("picture_height",$h);  
$Tpl->Parse("pic");  

Why is this? In simple terms, because you are enclosing a CCS generated
object within a custom block and the normal parsing is unable to find the
object. In reality, when the image component is asked to render (with its
Show method), the template engine is looking for that object in the parent
block, "Record frmPicture", but its actual location is "Record
frmPicture/pic".

You can remove the SetBlockVar. This method is only useful when you are
accumulating a custom block (the rows in a grid, for example), that you need
to clear before the next iteration.

To tell you the truth, unless you want to programatically hide or show the
column of the picture, there is no real need for a custom block. You can
simplify your code by removing the custom block tags and simply setting the
var value: e.g.

  
global $frmPicture;  
global $Tpl;  
list($w, $h) = getimagesize("images/parts/".$frmPicture->image->GetValue());  
$Tpl->SetVar("picture_height",$h);  

Regards,

Sixto

George L
Posted: 06/17/2004, 12:03 PM

Sixto, thank you very much for detailed explanation!

As I understand, in your 2nd example, on my HTML page I'll need only:
<td><img height="{picture_height}" src="/images/parts/{image}"></td>

I wish that CCS help file had your examples.

Thank you.
Sixto Luis Santos
Posted: 06/17/2004, 1:45 PM

You are very kind, but there is some actual documentation on this. Please
refer to
http://support.codecharge.com/kb_article.asp?article_id=56

The document does not cover your original problem, but it does the 2nd
example.

You must view the knowledge base as part of the general documentation for
the CodeCharge products.

Regards,
Sixto

<GeorgeL@forum.codecharge (George L)> wrote in message
news:240d1eb1f1f3f6@news.codecharge.com...
> Sixto, thank you very much for detailed explanation!
>
> As I understand, in your 2nd example, on my HTML page I'll need only:
> <td><img height="{picture_height}" src="/images/parts/{image}"></td>
>
> I wish that CCS help file had your examples.
>
> Thank you.
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.