n00dles / DM_Matrix

The Matrix is an XML file based Database system for GetSimple 3.1
8 stars 7 forks source link

Latest Version Issues #29

Closed outflux3 closed 12 years ago

outflux3 commented 12 years ago

I'm on GS 3.1 and when i go to the matrix, is is showing the hidden tables:

_routes 0 / 0 3 [Add Record] _settings 0 / 1 1 [Edit table] [Delete Table _settings] discography 1 / 0 11 [Edit table] [Add Record]

and there is no routes tab on the right.. Just wanted to report this.. everything else is working as before...

also, thanks for the credit! btw, alienee and outflux3 are same person..i used different username between github and gs forum..

cheers

n00dles commented 12 years ago

I've decided not to hide the hidden tables any more as its adds extra complexity to the plugin and I want to get it released sometime soon. Also decided we probably don't need the "_settings" table so that can be deleted, it was created in previous versions and unless your using it you can delete.

The "_routes" table is edited just like a normal table but it cannot be deleted as its required by the system.

Put a bit in the wiki on how to use..

outflux3 commented 12 years ago

Great thank you; everything seems to be working well, except i can't figure out how to access the elements of the array that is queried on the record page; i have the relevant query in my template., like this:

<?php 
$parts=explode('/',$uri);
$str=(string)$parts[1];
$myquery = "select * from discography where slug = '".$str."'"; 
$result=DM_query($myquery);
?>

and I have been trying to access the values in my template output with something like this:

<?php echo $result[album_title]; ?>

the other issue now is that the detail/record page shows this at the top of the page:

Array
(
    [0] => discography
    [1] => 2011-riptide
)
Array
(
    [0] => Array
        (
            [route] => discography
            [rewrite] => discog.php
        )

)

/home/user/dev/data/pages/discog.xml 
tablatronix commented 12 years ago

hmm well since we dont have select single row mode yet, your result will be an array. so if you are expecting a single row result set

$result[0]['album_title'];

you were also missing quotes around your index name.

outflux3 commented 12 years ago

Hey thanks; actually i had already tried that..(left out the quotes when i typed the message).. but still not able to get the values for the slug into the template...

doesn't the query already create the array of data for the relevant slug?

n00dles commented 12 years ago

@outflux3, debug code should be removed now. Do a print-r($result) to see the array values returned

outflux3 commented 12 years ago

I did try that but i'm just getting Array() on the output..

tablatronix commented 12 years ago

This is from the wiki

$myquery = "select * from testable where id = 1";  
$result=DM_query($myquery);
echo '<pre>'.print_r($result,true).'</pre>';

( cant get stupid code blocks to output properly) Try that with your query and see what the format is you get out. And post back please

outflux3 commented 12 years ago

Thanks, i'm able to get values when i specify an id; I am able to see the full array; will try pulling individual values and post back..

i'm having trouble with the query when comparing to the slug; I'll try some other ideas and re-post.

tablatronix commented 12 years ago

yeah thats why I would like to add a singlerow argument, so we can throw an exception if no results are returned and your expecting a single row. also for formatting the result as not an array. I am guessing your evaluation is failing and nothing is being returned.

n00dles commented 12 years ago

@outflux3, looking at the xml file you sent me a while ago, is your slug called 'album_slug' ?? or did you change it.

if so then the query should be:

$myquery = "select * from discography where album_slug = '".$str."'";

outflux3 commented 12 years ago

yes, i did change that, however i guess the engine doesn't like underscores in the query - once i changed the schema and table field to just slug, the query executes correctly; so 'album_slug' doesn't work, but 'slug' does, at least for the purposes of the select query parameters;

outflux3 commented 12 years ago

So aside from that issue with the query not working with the underscore, I've pretty much got everything working;

only last thing i need to do for this particular application is to be able to get an excerpt of my text field, for the listing page, so as to avoid having to have a custom teaser text..

Also, i copied the GS get_header() to my theme functions, and made one that uses the custom keywords and meta desc. for the matrix record; I can post in the wiki about that; i think this will end up being a must since most applications where a matrix record will become a page will need those fields;

tablatronix commented 12 years ago

I'll add this to be checked on in the reflex milestone.

Sent from my phone

On Jun 12, 2012, at 7:40 PM, outflux3 reply@reply.github.com wrote:

So aside from that issue with the query not working with the underscore, I've pretty much got everything working;

only last thing i need to do for this particular application is to be able to get an excerpt of my text field, for the listing page, so as to avoid having to have a custom teaser text..

Also, i copied the GS get_header() to my theme functions, and made one that uses the custom keywords and meta desc. for the matrix record; I can post in the wiki about that; i think this will end up being a must since most applications where a matrix record will become a page will need those fields;


Reply to this email directly or view it on GitHub: https://github.com/n00dles/DM_Matrix/issues/29#issuecomment-6289871

tablatronix commented 12 years ago

Regex*

n00dles commented 12 years ago

@tablatronix, what's the best way to archive the singlerow functionality. Are you saying we provide an argument to specify were expecting a sinlge row back? of do we check the returned array in DM_query, do a count and if its a single record return that single array rather the multidimesional array. Would that be easier?

n00dles commented 12 years ago

Also remember we have other ways to access the records

DM_getRecord($table,$id) - returns a single record in an array for the given table and ID getSchemaTable($table) - returns the complete table in a MD array.

If your not running queries on the tables these is the preferred methods.

I'll try and do a lot more docs tonight, have a couple of free nights from work this week so I'll try and get it finished by the weekend and released onto extend.

outflux3 commented 12 years ago

I wonder if there is any way to use the i18n search function for getting excerpts, in the context of Matrix.. , since most users will have i18n search installed, how to access these functions....

No rush on the excerpt thing, as for now i'm going to go with custom teaser text for the listing page, since that will complete this particular matrix application;

tablatronix commented 12 years ago

yeah a global second argument to modify the result array and to perhaps throw exceptions if the query returns unexpected results

DM_SINGLE ( 1 dimensional ) DM_MULTI ( multi dimensional, default ) DM_COUNT ( int )

I don't think its wise to return variable datatypes unless explicitly specified by the user. Could get confusing. Hence the second definition argument.

$r= DM_query('select * from table where primarykey = uniquevalue',DM_SINGLE);
// return array[0];
n00dles commented 12 years ago

@outflux3, One way i do the teaser text using a single content box is to put in a shortcode , say '[more]' in the text where you want the excerpt to end.

then output the content up to the shortcode for the excerpt and replace '[more]' with '' for the full content.

This way you have full control on the excerpt ends...

n00dles commented 12 years ago

@tablatronix, yeah that sounds great.

Will check it out when I get home...

outflux3 commented 12 years ago

@n00dles - ok great idea, better/more flexible than the 'getExcerpt' thing;, i'll make a shortcode for that and will post the code back here once i have it working...