Topic: xml structure

How can I create this structure in xml ?

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <options>
        <autoincrement>1</autoincrement>
    </options>
    <fields>
        <name/>
        <title/>
        <content/>
        <date/>
        <photo/>
    </fields>
    <galeria>
        <id>1</id>
        <uid>60a19eb042</uid>
        <name>otoño</name>
        <title>otoño en mallorca</title>
        <content>galeria content</content>
        <date>3/3/2013</date>´
            This
    =========================    
         <photo>
            <id>1</id>
            <title>one</title>
            <content>one text</content>
            <date>one date</date>
         </photo>
         <photo>
            <id>2</id>
            <title>two</title>
            <content>two text</content>
            <date>two date</date>
         </photo>
     ==========================  
    </galeria>
</root>
..::: Moncho Varela ::::..   ..::: @Nakome ::::..   ..::: Github ::::..

nakome's Website

Re: xml structure

http://monstra.org/documentation/xmldb-api

You must create two tables.

1) Table "galleries" with fields: name, title, content, date
2) Table "photos" with filelds: title, content, date, gallery_id

As is normal MySQL Database

But for better perfomance in Monstra: create new "photos" table for each "gallery" table 

1) Table "galleries" with fields: name, title, content, date
2) Table "photos_{gallery_id}" with filelds: title, content, date

Monstra Loves You! Give some love back!

Re: xml structure

1. first question

in install I put this:

Table::create('galeria', array('name','title','content','date'));
Table::create('photos',array('title','content','tags'));

And now in plugin.admin.php

    
$galeria = new Table('galeria');
$photos = new  Table('photos');

as I do this photos_{gallery_id}

2.question
how to do a foreach with 2 tables (array_combine?)

understand me

..::: Moncho Varela ::::..   ..::: @Nakome ::::..   ..::: Github ::::..

nakome's Website

Re: xml structure

Plugin Installation:
Create Table galleries

Table::create('galleries', array('name','title','content','date'));

Create new gallery (and create photos table too)

$galleries = new Table('galleries');
$galleries->insert('Gallery name', 'Gallery title', 'Gallery content', time());
Table::create('galleries_photos_'.$galleries->lastId(), array('name','title','content','date'));

This is just an Idea) Next you must write php logic for working with that tables. Actually it's part of backend development for backend developers )

I think it's deja vu, already discussed this somewhere here...

Monstra Loves You! Give some love back!

5 (edited by nakome 2013-01-17 18:05:12)

Re: xml structure

I have this code:

to delete the photo:

            if (Request::get('del_photo')) {
                if (Security::check(Request::get('token'))) {
                    $id = Request::post('id');
                    $galeria->deleteWhere($id);
                    Request::redirect('index.php?id=sandbox');
                } else { die('csrf detected!'); }
            }

to view photos:

<ul class="photos">
    <?php if (count($records) > 0) foreach ($records as $row) { ?>
        <li class="photo">
            <div class="photo-img"><img src="<?php echo $row['img']; ?>" alt="<?php echo $row['title']; ?>"/></div>
            <div class="photo-title"> <h3><?php echo $row['title']; ?></h3></div>
            <div class="photo-content"><p><?php echo $row['content']; ?></p></div>
            <div class="photo-tags"><small>Tags: <?php echo $row['tags']; ?></small></div><hr>
            <?php echo Html::anchor(__('Delete', 'sandbox'), 'index.php?id=sandbox&del_photo='.$row['id'].'&token='.Security::token(), array('class' => 'btn btn-actions', 'onClick'=>'return confirmDelete(\''.__('Are you sure', 'sandbox').'\')')); ?>
        </li>
    <?php } ?>
</ul>

Why delete first image  on click  in other image?

..::: Moncho Varela ::::..   ..::: @Nakome ::::..   ..::: Github ::::..

nakome's Website

Re: xml structure

I've solved thanks.

..::: Moncho Varela ::::..   ..::: @Nakome ::::..   ..::: Github ::::..

nakome's Website