Block with thumbnail/title/linked URL?
PermalinkI'm trying to create a block that contains a thumbnail field, a title field, and a URL field that will wrap around a small icon with a rollover.
Here's a screenshot of what I'm trying to do:
http://imgur.com/oI67s.jpg
I'm new to PHP and am fumbling hopelessly, trying to get this to work. Any help would be awesome. Here's what I have for the block:
add.php:
controller.php:
<?php class BasicTestBlockController extends BlockController { var $pobj; protected $btDescription = "A simple testing block for developers."; protected $btName = "Basic Test"; protected $btTable = 'btBasicTest'; protected $btInterfaceWidth = "350"; protected $btInterfaceHeight = "300"; } ?>
db.xml:
<?xml version="1.0"?> <schema version="0.3"> <table name="btBasicTest"> <field name="bID" type="I"> <key /> <unsigned /> </field> <field name="fID" type="I"> <unsigned /> <default value="0" /> </field> <field name="content" type="X2"> </field> </table> </schema>
edit.php:
<?php $al = Loader::helper('concrete/asset_library'); echo $al->file('ccm-b-file', 'fID', t('Choose File'), $bf) ?> <?php echo $form->label('content', 'Name');?> <?php echo $form->text('content', $content, array('style' => 'width: 320px'));?> <?php $file = File::getByID($fID); $filePath = $file->getVersion()->getRelativePath();?>
view.php:
I'm sure it's something relatively simple, but to the PHP beginner it's a little overwhelming. Thanks for help!

I've tried many variations that I've tried to extract from concrete's standard blocks, with no luck.
If you really want to make it your own block, Remo also has a good sample block you can base yours off of here:http://www.codeblog.ch/2009/06/concrete5-staff-table/...
I'm not sure that going the route of a custom template would be the best or most efficient choice since I already have all the content (with the exception of the thumbnail and link) built into a block. I'm not familiar enough (yet) with PHP syntax to successfully extract only the information that I need from the preexisting page_list template...
The block I have (each component shown in my original post, above) works great right now as it is, I just need a bit of help or helpful steering that will show me what I need to do, or add, to what I already have, to make the extra 2 fields I need.
Is it as simple (relatively) as taking this part of the code in view.php:
<?php echo '<img src="' . $filePath . '" />'; ?>
And wrapping it in something like...
<?php echo '<a href="' . $linkPath . '"> <img src="' . $filePath . '" /> </a>'; ?>
?
(That of course doesn't work, but am I headed in a vaguely good direction? And if so, what do I need to add to the db.xml?)
$filePath = $file->getRelativePath($fID); ///Alternative $filePath = File::getRelativePathFromID($fID);
using either should give you the path to the most recent version
What I want to do is have 1 field for a thumbnail, and 1 field for a URL that will wrap around the thumbnail so the _effect_ is:
<a href="#"><img src="image.jpg"></a>
I have an existing block with a couple other fields. All I want to do is add these 2 additional fields. Is this doable?
this should be relatively simple
If you're not getting an image displayed there check that the fID is saving and being fetched..
then the problem would be the edit/add(.php)
Also the image block can do this out of the box..
Thank you so much for your help so far, though. I know it's a lot to ask, for programmers to take time out of their day to help us little guys (and girls)! So, much appreciated. :)
_______________
http://moviesonlinefree.biz