Block with thumbnail/title/linked URL?
Permalink
Hi everyone,
I'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:
db.xml:
edit.php:
view.php:
I'm sure it's something relatively simple, but to the PHP beginner it's a little overwhelming. Thanks for help!
I'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!
Anyone? :(
You haven't actually stated what the problem is..?
Oh sorry! I'm trying to create a field for a URL that wraps around an image, so that the image is linked.
I've tried many variations that I've tried to extract from concrete's standard blocks, with no luck.
I've tried many variations that I've tried to extract from concrete's standard blocks, with no luck.
You can accomplish the same thing you are trying to do with your block by using a custom template with the page list block. By default, the page list block will show the title of a page, the description, and the link to the actual page. Following this tutorial shows how to easily add a thumbnail as well:http://www.codeblog.ch/2009/03/concrete5-templates...
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/...
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/...
Thank you, I will look into this right away!
Okay, I followed Remo's tutorial, and got this error: "Fatal error: Call to a member function getFileRelativePath() on a non-object in [path]/blocks/page_list/templates/thumbnail.php on line 18"
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:
And wrapping it in something like...
?
(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?)
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
opps forgot the File::getByID() call on the first one.. but you got the idea
wait maybe I'm misunderstanding.. Do you need the Concrete5 Page Selection Popup for your link?
No, not the Page Selection.
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?
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?
Thanks, but this didn't work. :(
Is the fID set? have you echo'd it out to verify it's saving ?
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)
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)
Thank you for this, I'm going to try it out now, I just need to know which file(s) to add it to. Are you saying I need to add that code to both the edit.php and add.php?
what I provided would be what I think you want in your view? a Image wrapped in a URL ? If not then I am confused..
Also the image block can do this out of the box..
Also the image block can do this out of the box..
I think I may have found the answer in the preexisting "Image" block (fingers crossed).
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. :)
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. :)
Great post! It's very nice. Thank you so much for your post.
_______________
http://moviesonlinefree.biz
_______________
http://moviesonlinefree.biz