how do I use a database in C5 while providing easy/safe access for my client?

Permalink
I'm used to developing web sites using php and mysql databases and for example pulling data from the db in order to display images on a results page. I would normally use a query string such as
<a href='results.php?search=chairs'>go</a>


The results page would grab the global variable GET and store the value which would be the parameter for the mysql query. That way I could display relevant search results using one page rather than many.

I could do the same in C5 but I want the client to be able to add, display and delete data from the database without actually having to go into phpmyadmin or mysql buddy etc, but instead use the editable areas common to C5.

Does anyone have any idea how I would accomplish this in C5?

 
beebs93 replied on at Permalink Reply
beebs93
Maybe I'm missing something, but what your describing sounds like how concrete5's search block generally operates. A $_GET variable is passed to a search results page which feeds that into a complex MySQL query which in turn, by default, returns the page name, a short description with highlighted text and a link to said page for each result.

If you wanted an icon to appear next to each page result as you mentioned in your example, then that'd probably be a simple matter of using an image/file page attribute assigned to pages which is looked up for each result when a search request is made.

<?php
// Example code; not exact syntax being used
foreach($results as $result){
   $icon = $result->getAttribute('page_icon');
   $icon_path = $icon->getVersion()->getRelativePath();
   // display the normal search result here along with an <img> tag with the $icon_path as its "src" attribute
}
?>


If you wanted to simply do an image search then I'd approach it by using a dedicated page template as the results page (or a single page) and, utilizing the File List model in the C5 core, do a search for files based on keywords and possibly extensions (only JPGs, or PNGs, etc).

Any of this data, be it pages or images, are inserted into C5's database through its dashboard (Page sitemap or file manager) so your client will never have to (and never should, really) have to play around with phpMyAdmin.

Sorry for crop dusting your question with a bunch of answers since I'm not 100% sure what your specifically trying to do.

EDIT: I found your original post here (http://www.concrete5.org/community/forums/customizing_c5/need-some-advice-on-search-page) so ignore all but my last suggestion.