Newbie question about customizing blocks

Permalink
Hi, I'm new to C5 so please bear with me.

I want to create a customized block for the gallery section of a site. I read the documentation and installed the Basic Test, and have tried to modify it, to no avail.

Block requirements for gallery: "Title" (title of artwork), "Thumbnail" (picture of artwork), "Link" (arrow icon that links to URL of artwork).

add.php looks like this:

<?php echo $form->label('content', 'Title');?>
<?php echo $form->text('content', array('style' => 'width: 320px'));?>

<?php echo $form->label('content', 'Thumbnail');?>
<?php echo $form->file('content', array('style' => 'width: 320px'));?>

<?php echo $form->label('content', 'Link');?>
<?php echo $form->text('content', array('style' => 'width: 320px'));?>

edit.php looks like this:

<?php echo $form->label('content', 'Title');?>
<?php echo $form->text('content', $content, array('style' => 'width: 320px'));?>

<?php echo $form->label('content', 'Thumbnail');?>
<?php echo $form->file('content', $content, array('style' => 'width: 320px'));?>

<?php echo $form->label('content', 'Link');?>
<?php echo $form->text('content', $content, array('style' => 'width: 320px'));?>

db.xml has not been modified and looks like this:

<?xml version="1.0"?>
<schema version="0.3">
<table name="btBasicTest">
<field name="bID" type="I">
<key />
<unsigned />
</field>
<field name="content" type="X2">
</field>
</table>
</schema>

I've tried many variations to these three files, including db.xml, and also remembered to refresh the block in the database, but when I add the block within the CMS on the gallery page, enter the fields and hit save, only one of the fields shows up on the gallery page. Other variations have worse results.

Thank you so much for any help, it'll be very much appreciated. I'm sure it's something relatively simple, but as a front-end developer I'm new to PHP. Thanks again!

stephmars
 
Tony replied on at Permalink Reply
Tony
each field needs a unique name (not content), and then you need to make matching names in the database schema (don't use X2 for these).
stephmars replied on at Permalink Reply
stephmars
Hi, Tony, thank you for your comment! I think it might point me in the right direction. Could you provide a brief example for me of making a matching name in the database? Would this be correct?:

for add.php:

<?php echo $form->label('newname', 'Thumbnail');?>
<?php echo $form->file('newname', array('style' => 'width: 320px'));?>

for db.xml:

<?xml version="1.0"?>
<schema version="0.3">
<table name="btBasicTest">
<field name="bID" type="I">
<key />
<unsigned />
</field>
<field name="content" type="X2">
</field>

<field name="bID" type="I">
<key />
<unsigned />
</field>
<field name="newname">
</field>
</table>
</schema>

I'm probably way off, so any other guidance would be much appreciated. Thanks again.
Tony replied on at Permalink Reply
Tony
you probably should have a look at some of the other concrete5 blocks to see how it's done.

if it's a string of text, use this database column type:

<field name="shownAttributes" type="C" size="255"></field>

If it's a huge blob of text, then use "X2".

And if it's integer use "I"
stephmars replied on at Permalink Reply
stephmars
THANKS!! I will try to work this out.

As for bID... Could you help point me in the right directions as far as finding out what that means and what other types are? Thanks thanks thanks so much.

Edited: Nevermind, I found this site (http://phplens.com/lens/adodb/docs-datadict.htm) with a list of the other types. Also, the field example you gave me didn't work, but I'm going to keep trying variations of it. Maybe I'll blindly hit upon the solution. Thanks again for your help.