How to make a block with related tables

Permalink
I am new to developing for Concrete 5, and have taken a look at 'Making Your Own Blocks' section, but don't understand how to create a block with 2 related tables... And how to add/edit/view them.

Hope somebody can help me.

gleert
 
okhayat replied on at Permalink Reply
okhayat
AFAIK, if you have more than one table, you have to deal with them using SQL.
cgrauer replied on at Permalink Reply
cgrauer
I don't know what you intend to do with two tables for a block, but perhaps you should think of building a package.
gleert replied on at Permalink Reply
gleert
I want to make a simple links block where the links can be grouped....
So I need a table for groups and a table for links.

Any idear on how to do this ??
cgrauer replied on at Permalink Reply
cgrauer
Do you want to let the user write down the links every time he places a block on a page or do you want to store the links for global use?

In the first case you just have to add an additional field to your block for the grouping criteria and ask the user to fill it with data. If you want fixed categories just make it a selection-field and hardcode the options in your controller.php

In the second case you have to build a package with a separate table and a dashboard page to edit the links. You can access this table then from your block using SQL and the c5 API.

I'm just writing a package with similar functionality for contacts, news and scheduler functions and even every sort of tabled data to use on the pages. It's not perfect yet but I use it already in a production site and it works fine. I could easily change the contacts block to fit for links. Tell me, what you need (fields, categories etc.) and I'll have a look on it, if you want.
gleert replied on at Permalink Reply
gleert
The second option would be the correct one for me. I would like to show all the links grouped by group on 1 page...

It would be great if you could do this for me!!

Groups table:
Title

Links table:
Title
Link
Number (for internal use, does not show on the page)

Please let me know what you can do for me. Thanks in advance.
cgrauer replied on at Permalink Reply
cgrauer
ok, just give me a couple of hours...

Do you want a 1:n or a n:n relation between links and groups? i.e. put one link in more than one groups?

Do you want number to be a integer value or a string?
gleert replied on at Permalink Reply
gleert
The relation between links and groups is 1:n !

The number as an integer please.

Hope to hear from you soon.
cgrauer replied on at Permalink Reply 1 Attachment
cgrauer
Here we are...

Please consider that it's software under developement. Use it on your own risk! Backup your installation and data before testing it. I tested it on two websites and it worked fine, but we know that Murphy is waiting around the next corner... So really DO BACKUP everything!

Some features still do not work (e.g. the delete button) or look creepy. Please bear with me.

To install just copy the content of the zip under your installation's "packages" folder and go to the dashboard and install it using "Add Functionality".

I hope it works for you... Just go to /dbee/blocks/dbee_links/view.php to customize the blocks for your need. There are some extra informations in the file itself.

(If anyone else wants to use it, please do so, but do give me a message to cgrauer@netscript.net!! I want to know who's playing with my toys ;-))
gleert replied on at Permalink Reply
gleert
Thanks a lot...

I will be installing it asap! Will let you know how things are going... Thanks again.