Couple of questions

Permalink
Hello conrete5 devs

I recently started on a package for the conrete5 system. I miss some code examples in the documentation on how to basic things. (Maybe i just cant find it?) I therefore have a couple of questions.

The package i am working on is a simple newssystem. Its going to work like that you insert and edit news in the dashboard and you got a block for viewing top x news.

1) How should tables be initialized ? As it is now i create them in db.xml in the block folder. Would it be more appropiate in the package folder(if possible?

2) In the dashboard when creating news. How do i insert into a created table?
If i for example have (in my dashboard controller):

public function add_news() {
$pkg = Package::getByHandle('hummus_news');
$this->set('message',t('Jeg tester lige.'));
}

I really could use some code examples showing how to manipulate data in the database.

.. and sorry for my bad english - im from Denmark :)

s0mmer
 
Mnkras replied on at Permalink Reply
Mnkras
take a look at the form block included in the core it is located in /concrete/blocks

Mike
kalaiprakash replied on at Permalink Reply
kalaiprakash
1. Create a sample package, lets say 'newspackage' inside package directory, in that create db.xml file
<?xml version="1.0"?>
<schema version="0.3">
<table name="btnews">
<field name="bID" type="I">
<key />
<autoincrement />
<unsigned />
</field>
<field name="heading" type="C" size="50">
</field>
<field name="date" type="T">
</field>
<field name="description" type="X2">
</field>
</table>


2. Write this function in \packages\newspackage\controllers\dashboard\newspackage\controller.php or use single pages. Check this free addon Database manager,http://www.concrete5.org/marketplace/addons/database-manager/...
s0mmer replied on at Permalink Reply
s0mmer
kalaiprakash > Thank you very much. Your answer on 1) was exactly what i needed. I didnt knew if C5 was checking the package dir for a db.xml.

And 2) is exactly how i did. I must admit that after finding the $db->query("SQL QUERY") function it was a ease to write my package done.

Once again, thanks for your guidance.

This website stores cookies on your computer. These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media. To find out more about the cookies we use, see our Privacy Policy.