Hi everyone,
I would like to add a 'div' in the '#content' of my file 'index.php' with automatically the section name.
I'm using the system variable .
It works with exhibit title , but not with section name ?
Thanks in advance
J.
Hi everyone,
I would like to add a 'div' in the '#content' of my file 'index.php' with automatically the section name.
I'm using the system variable .
It works with exhibit title , but not with section name ?
Thanks in advance
J.
Section name is not available as a variable. I've posted a few times the way to make this happen...you will need to add ndxz_section to the query in your root index.php. But have a search for the full answer...
Thanks for your answer.
I'm sorry ! I've made some researches on the forum but I haven't found what you are talking about...
Maybe you can help me to find the link I'm looking for ? (It would be very helpfull).
Thanks in advance
J.
// page query$rs = $OBJ->db->fetchRecord("SELECT * FROM ".PX."objects, ".PX."objects_prefs, ".PX."sections WHERE url = '$uri' AND status = '1' AND section_id = secid AND object = obj_ref_type");Look for "page query" in the root index.php file and then replace the query with this one which has the sections parts added.
Now, you can access 'sec_desc' to get the name of the section. Consult the database for the other variables this makes possible as well.
Great, it works fine!
Thank you very much Vaska.
Have a nice day,
J.
as the example above, I've adjusted the root index.php and I've tried this in the site/mysite/index.php<div class='<%sec_desc%>'></div>Tried as well this call in the text area and in the plugin (where I'd like to have also that section name)
$a .="<p><a href='#' onclick="swap(); return false;"><b>«</b> Back to <b><%title%></b> | <b><%sec_desc%></b> thumbnails</a> | ";(I think the code above will be a mess, though the point should be understandable)
tried as well many combinations, but can't make it work...
what am I missing?
Could it be possible to generate a variable for media_file?
by adding
".PX."mediaas well as
AND media_ref_id = id? but i dont think its that simple.
Not really. What are you trying to do...
I would like to have the media_file name as a system variable to use within a plugin on a page.
Ive tried using a plugin for the same purpose but its a bit long winded.
But, you could have possible many "media_file"s for a single page. More specifically, what are you trying to do...
i understand that, i wanted a system varible that was for the first media_file on each page to enter into a custom plugin which would pass to an external page out side of the indexhibit folder.
its no matter tho, i ended up trying another method, by adding a query to the plugin to pull the media file direct from the database.
Another question, is it possible to pass one variable from a plugin to another? for example if i had a form with in a plugin in the pre nav box, and wanted the results displayed on another page by another plugin.
Yes, that would be my suggestion...have the plugin query get the media_file info you need.
Display the results in another page? You mean, passing the info via $_POST or $_GET?
yeah, building a search function
this is what i have so far, it gets results for title, but im having errors getting any by searching two tables/columns in the query, eg sec_desc and title.
sec_desc is the one im having difficulty with.
function search(){$term = $_POST['term'];$OBJ =& get_instance();
global $rs;
$pages = $OBJ->db->fetchArray("SELECT id, media_file, url, media_order, media_id, title, media_title, sec_ord, secid, ord, sec_desc
FROM ".PX."objects, ".PX."sections, ".PX."media
WHERE media_ref_id = id
AND title LIKE '%$term%'
AND hidden != '0'
AND status = 1
AND section_id = secid
AND media_order = (SELECT MIN(media_order) FROM ".PX."media WHERE media_ref_id = id )
ORDER BY sec_ord ASC, ord ASC ");
code again.
function search(){$term = $_POST['term'];$OBJ =& get_instance(); global $rs; $pages = $OBJ->db->fetchArray("SELECT id, media_file, url, media_order, media_id, title, media_title, sec_ord, secid, ord, sec_desc FROM ".PX."objects, ".PX."sections, ".PX."media WHERE media_ref_id = id AND title LIKE '%$term%' AND hidden != '0' AND status = 1 AND section_id = secid AND media_order = (SELECT MIN(media_order) FROM ".PX."media WHERE media_ref_id = id ) ORDER BY sec_ord ASC, ord ASC ");The seearch should be returning just info regarding to pages?
Also, I think I would broaden the search and go through 'content' as well...
AND (title LIKE '%$term%' OR content LIKE '%term%')And be sure you validate the $term. You can tap into the validation functions from the frontend as well...
$P = load_class('processor', true, 'lib');And there you go...validation functions... ;)
Just realized, maybe I answered your question but used 'content' instead of 'sec_desc'?
thanks vaska.
just added that, i think ive put the validation in the right place?
ive also played with the keywords entered so it doesnt need an exact match to return results.
see bellow.
function search(){$var = @$_GET['term'] ; $trimmed = trim($var);$trimmed_array = explode(" ",$trimmed);$P = load_class('processor', true, 'lib');foreach ($trimmed_array as $trimm){$OBJ =& get_instance();global $rs; $pages = $OBJ->db->fetchArray("SELECT id, content, media_file, url, media_order, title, media_title, sec_ord, secid, ord, sec_desc FROM ".PX."objects, ".PX."sections, ".PX."media WHERE media_ref_id = id AND (title LIKE '%$trimmed%' OR sec_desc LIKE '%$trimm%' OR content LIKE '%$trimm%') AND hidden != '0' AND status = 1 AND section_id = secid AND media_order = (SELECT MIN(media_order) FROM ".PX."media WHERE media_ref_id = id ) ORDER BY sec_ord ASC, ord ASC");if people are interested i can release this as a simple search function with or with out images, maybe link / title instead?
Sure, if you are up for it...but...I don't see any actual validation going on there.
by validation what do you mean, that theres a keyword entered? or if results will show.
i have this which returns 'no results' if there is either nothing found or no term entered.
$t =''; $t .= "No Results for: $trimmed"; $b = 'No Results';if (!$pages) return $t; if ($trimmed == "") return $b;;No, I mean people could easily take control of your website via mysql injection if you don't validate the inputs.
ok, so ive had a look at mysql injection and included addslashes and mysql_real_escape_string for validation.
ive also added an AND to the query for a more refined search result for more than one keyword entered.
i can only search one field though, as it returns with a fatal error from the server for more than one, as the search exceeds the allowed limit for the script. i cant find a way round this, a part from asking my host to raise the limit?
function search(){$var = addslashes(htmlspecialchars(@$_GET['term'])) ;$trimmed = trim($var);//validation on unwanted characters $trimmed = mysql_real_escape_string($trimmed);//separate key-phrases into keywords$trimmed_array = explode(" ",$trimmed);// count keywords$trimm_total = count($trimmed_array);$i = 0;$searchstring = '';// looping to get the search stringforeach ($trimmed_array as $trimm){ if ($i != 0 and $i != $wordcount) { $searchstring .= " AND "; } $searchstring .= "content LIKE '%$trimm%'"; // incrementing the value $i = $i + 1; }$OBJ =& get_instance(); global $rs; $pages = $OBJ->db->fetchArray("SELECT * FROM ".PX."objects, ".PX."sections, ".PX."media WHERE $searchstring AND media_ref_id = id AND status = 1 AND section_id = secid AND media_order = (SELECT MIN(media_order) FROM ".PX."media WHERE media_ref_id = id ) ORDER BY sec_ord ASC, ord ASC "); $t =''; $t .= "No Results Found";$b = 'No Results - Please Enter a Search Value' ; if (!$pages) return $t; if ($var == "") return $b;You need to be logged in to post.