Imageupload in a block
Permalink
Hello,
I'm currently developing with concrete5. I have stumbled upon a problem where I am uploading an image using the concrete5 the following code.
In the db.xml, I have declared 'afbeelding' as followed.
For some how, if I echo the variable $afbeelding it only gives me the ID of the image, for instance 20 or 19.
I need to generate the image path from this ID or I need an alternative way to get this image path. Could anyone please help me?
Jim
I'm currently developing with concrete5. I have stumbled upon a problem where I am uploading an image using the concrete5 the following code.
<?php $al = Loader::helper('concrete/asset_library'); echo $al->file('afbeelding', 'afbeelding', 'Selecteer foto'); ?>
In the db.xml, I have declared 'afbeelding' as followed.
<field name="afbeelding" type="B"> <default value="" /> </field>
For some how, if I echo the variable $afbeelding it only gives me the ID of the image, for instance 20 or 19.
I need to generate the image path from this ID or I need an alternative way to get this image path. Could anyone please help me?
Jim
Ok, I fixed it. Thanks!
This is the code of my block
And this is the layout of my db.xml
Somehow, the 'ondertitel' and 'sound' are not saving. Does anyone of you know how to solve this? The rest of the fields are saving perfectly.
This is the code of my block
<?php defined('C5_EXECUTE') or die(_("Access Denied.")) ?> <div class="ccm-ui"> <div class="alert-message block-message info"> <?php echo t("Voeg een product toe.") ?> </div> <?php echo $form->label('titel', t('Titel')) ?> <?php echo $form->text('titel', $title) ?> <?php echo $form->label('sound', t('Uitspraak')) ?> <?php echo $form->text('sound', $sound) ?> <?php echo $form->label('ondertitel', t('Ondertitel')) ?> <?php echo $form->text('ondertitel', $ondertitel) ?> <?php echo $form->label('omschrijving', t('Omschrijving')) ?> <?php echo $form->textarea('omschrijving', $omschrijving) ?> <?php echo $form->label('prijs', t('Prijs')) ?> <?php echo $form->text('prijs', $prijs) ?>
Viewing 15 lines of 20 lines. View entire code block.
And this is the layout of my db.xml
<?xml version="1.0"?> <schema version="0.3"> <table name="btBasicTest"> <field name="bID" type="I"> <key /> <unsigned /> </field> <field name="omschrijving" type="X2"> <default value="" /> </field> <field name="titel" type="C" size="255"> </field> <field name="prijs" type="X2"> <default value="" /> </field>
Viewing 15 lines of 24 lines. View entire code block.
Somehow, the 'ondertitel' and 'sound' are not saving. Does anyone of you know how to solve this? The rest of the fields are saving perfectly.
Nothing jumps out as the reason from your code. You can put some diagnostics in a block controller save method and check whether the data gets that far...
http://www.concrete5.org/documentation/how-tos/developers/concrete5...
function save($data){ // dump $data to log as per howto parent::save($data); }
http://www.concrete5.org/documentation/how-tos/developers/concrete5...
Alright, last question dude. As soon as I edit a block that includes an image, the file selector doesn't auto select the image that originally was selected. Is there a way in which I can auto select this image? Thanks for your help so far!
http://www.concrete5.org/documentation/developers/files/files-and-f...
and then:
http://www.concrete5.org/documentation/developers/files/helpers/...
You can use the file object to get the image as an object from the ID and then get the current version, then the file version object gets passed to the image helper to output a tag.
There are also methods for thumbnailing, or just getting a url so you can build your own tag.