MyBB Community Forums

Full Version: Adding text to the top of tutorials.php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have installed the tutorials mod made by Casey at MybbPlanet. At the top of the tutorials pages, I would like to add something like "To add a tutorial, contact us". I am not a php coder, and whenever I try to enter that text, it gives me a parse error. Here is my tutorials.php code:
<?php
require "./global.php";
$lang->load("index");

// the menu that goes on all pages
	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."tut_cats ORDER BY `cat` ASC");
	while($cat = $db->fetch_array($query)) {
	$cats .= "<b>+</b>&nbsp; <a href='?action=viewcat&id=$cat[id]'>$cat[cat]</a><br />";
	}
	eval("\$menu .= \"".$templates->get("tuts_menu")."\";");



if($action == "viewall") {

	addnav("Tutorial Database","tutorials.php");
	addnav("Viewing All Tutorials");
	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."tutorials ORDER BY `id` DESC");
	$num = $db->num_rows($query);
	if($num < 1) {
	eval("\$tutorials_row= \"".$templates->get("tuts_error_none")."\";");
	}
	while($tut = $db->fetch_array($query)) {
	$cat = $db->fetch_array($db->query("SELECT * FROM ".TABLE_PREFIX."tut_cats WHERE `cat`='$tut[cat]'"));
	eval("\$tutorials_row.= \"".$templates->get("tuts_viewall_row")."\";");
	}
	eval("\$tuts = \"".$templates->get("tuts_viewall")."\";");

} 



else if($action == "viewcat") {

	addnav("Tutorial Database","tutorials.php");
	addnav("Viewing Category");
	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."tut_cats WHERE `id`='$id'");
	$num_rows = $db->num_rows($query);
	if($num_rows < 1) {
	eval("\$nocat .=\"".$templates->get("tuts_cat_none")."\";");
	outputpage($nocat);
	} else {
	$query2 = $db->query("SELECT * FROM ".TABLE_PREFIX."tut_cats WHERE `id`='$id'");
	$k = $db->fetch_array($query2);
	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."tutorials WHERE `cat`='$k[cat]' ORDER BY `id` DESC");
	$num = $db->num_rows($query);
	if($num < 1) {
	eval("\$tutorials_2= \"".$templates->get("tuts_error_none_cat")."\";");
	}
	while($tut = $db->fetch_array($query)) {
        eval("\$tutorials_2 .= \"".$templates->get("tuts_cat_row")."\";");
	}
	addnav("$k[cat]");
	eval("\$tuts = \"".$templates->get("tuts_cat")."\";");
	}

} 



else if($action == "viewtut") {

	require "./inc/functions_post.php";
	addnav("Tutorial Database","tutorials.php");
	addnav("Viewing Tutorial");
	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."tutorials WHERE `id`='$id'");
	$num_rows = $db->num_rows($query);
	if($num_rows < 1) {
	eval("\$notut .=\"".$templates->get("tuts_viewtut_none")."\";");
	outputpage($notut);
	} else {	
	$kk = $db->fetch_array($db->query("SELECT * FROM ".TABLE_PREFIX."tutorials WHERE `id`='$id'"));
	$up = "SET views=$kk[views]+1";
	$update = $db->query("UPDATE ".TABLE_PREFIX."tutorials $up WHERE `id`='$id'");
	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."tutorials WHERE `id`='$id'");
	$tut = $db->fetch_array($query);
	addnav("$tut[name]");
	if(!$mybb[uid]) {
	eval("\$sub_com .=\"".$templates->get("tuts_viewtut_com_no")."\";");
	} else {
	eval("\$sub_com .=\"".$templates->get("tuts_viewtut_com_yes")."\";");
	}
	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."tut_comments WHERE `tid`='$id' ORDER BY `id` ASC");
	$num_rows = $db->num_rows($query);
	if($num_rows < 1) {
	eval("\$comments .= \"".$templates->get("tuts_viewtut_comments_none")."\";");
	} else {
	$altbg = "trow2";
	$i=0;
	while($com = $db->fetch_array($query)) {
	$i++;
	if($mybb[usergroup] == "3" || $mybb[usergroup] == "4" || $mybb[usergroup] == "6"){
	$del = " | <a href='?action=delete_com&id=$com[id]&tid=$tut[id]'>Delete?</a>";
	} else {
	$del = "";
	}
	
	eval("\$comments .= \"".$templates->get("tuts_viewtut_comments")."\";");

	}
	}
	eval("\$tuts .=\"".$templates->get("tuts_viewtut")."\";");
	}

}



else if($action == "highrated") {

	addnav("Tutorial Database","tutorials.php");
	addnav("Viewing Highest Rated Tutorials");
	$what = "Rated";
	$high = $db->query("SELECT * FROM ".TABLE_PREFIX."tutorials ORDER BY `rating` DESC");
	$num = $db->num_rows($high);
	if($num < 1) {
	eval("\$tutorials_row= \"".$templates->get("tuts_error_none")."\";");
	}
	while($tut = $db->fetch_array($high)) {
	$cat = $db->fetch_array($db->query("SELECT * FROM ".TABLE_PREFIX."tut_cats WHERE `cat`='$tut[cat]'"));
	eval("\$tutorials_row.= \"".$templates->get("tuts_index_row")."\";");
	}
	eval("\$tuts = \"".$templates->get("tuts_highest")."\";");

} 



else if($action == "highviewed") {

	addnav("Tutorial Database","tutorials.php");
	addnav("Viewing Highest Viewed Tutorials");
	$what = "Viewed";
	$views = $db->query("SELECT * FROM ".TABLE_PREFIX."tutorials ORDER BY `views` DESC");
	$num = $db->num_rows($views);
	if($num < 1) {
	eval("\$tutorials_row= \"".$templates->get("tuts_error_none")."\";");
	}
	while($tut = $db->fetch_array($views)) {
	$cat = $db->fetch_array($db->query("SELECT * FROM ".TABLE_PREFIX."tut_cats WHERE `cat`='$tut[cat]'"));
	eval("\$tutorials_row.= \"".$templates->get("tuts_index_row")."\";");
	}
	eval("\$tuts = \"".$templates->get("tuts_highest")."\";");

}



else if($action == "rate") {

	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."tutorials WHERE `id`='$id'");
	while($ra = $db->fetch_array($query)) {
	$numvotes = $ra['voters'];
	$currentrating = $ra['rating'];
	$rating = $_POST['rate'];
	$new_count = ($numvotes + 1);
	$rating2 = ($currentrating * $numvotes);
	$newrating = (($rating + $rating2) / ($new_count));
	$newrating2 = number_format($newrating, 2, '.', ''); 
	$update = $db->query("UPDATE ".TABLE_PREFIX."tutorials SET rating=$newrating2,voters=$new_count WHERE `id`='$id'");
	eval("\$tuts = \"".$templates->get("tuts_option_rated")."\";");
	}

} 



else if($action == "comment") {

	require "./inc/functions_post.php";
	$comment = $_POST['comment'];
	$date = date("M dS, Y");
	if($comment == "") {
	eval("\$comm2 = \"".$templates->get("tuts_option_commented_no")."\";");
	outputpage($comm2);
	} else {
	$comment = postify($comment, $settings['tuts_html'], $settings['tuts_mycode'], $settings['tuts_smilies'], $settings['tuts_img']);
	$comment = str_replace("'",''', $comment);
	$comment = str_replace("\\",'\', $comment); 
	$comment = str_replace("\/",'/', $comment); 
	$insert = $db->query("INSERT INTO ".TABLE_PREFIX."tut_comments (tid, name, comment, date, uid)VALUES('$id','$mybb[username]','$comment','$date','$mybb[uid]')");
	if($settings['tuts_postcount'] != "no") {
	$kk2 = $db->fetch_array($db->query("SELECT * FROM ".TABLE_PREFIX."users WHERE `uid`='$mybb[uid]'"));
	$up = "SET postnum=$kk2[postnum]+1";
	$update = $db->query("UPDATE ".TABLE_PREFIX."users $up WHERE `uid`='$mybb[uid]'");
	}
	eval("\$tuts = \"".$templates->get("tuts_option_commented")."\";");
	}

}



else if($action == "delete_com") {

	if($mybb[usergroup] == "3" || $mybb[usergroup] == "4" || $mybb[usergroup] == "6") {
	$query = $db->query("DELETE FROM ".TABLE_PREFIX."tut_comments WHERE `id`='$id' LIMIT 1");
	eval("\$tuts .= \"".$templates->get("tuts_option_delcomments")."\";");
	} else {
	eval("\$tuts .= \"".$templates->get("tuts_option_delcomments_no")."\";");
	}

}



else {

	addnav("Tutorial Database");
	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."tutorials ORDER BY `id` DESC LIMIT 10");
	$num = $db->num_rows($query);
	if($num < 1) {
	eval("\$latest_row = \"".$templates->get("tuts_error_none")."\";");
	}
	while($tut = $db->fetch_array($query)) {
	$cat = $db->fetch_array($db->query("SELECT * FROM ".TABLE_PREFIX."tut_cats WHERE `cat`='$tut[cat]'"));
	eval("\$latest_row .= \"".$templates->get("tuts_index_row")."\";");
	}
	eval("\$tuts .= \"".$templates->get("tuts_index")."\";");

}

outputpage($tuts);
?>

Could someone please add that text in for me? Thanks!
I cant help a real lot, but what I think you are trying to do is add text to a template... If so you would need to add it to either a "global" or fixed template.

By adding 'unqualified' text to the php file and not coding it with command options on how to behave.... I'm sure you are going to break the existing code and get parse errors.

Take a 'snapshot' of what you are trying to do and where it has to go... and supply a link to the image; so there is a better understanding of what you are trying to achieve.

If it's above my expertise, then at least it will be clearer on what you want to do to someone who can help.
You dont add text via php file. Open up the template tuts_index in the Admin CP and add it in there (and other templates starting to tuts_ if you wish).
Thanks, but I don't see a tuts_index on the templates list.
Well, it will be there if you can view the tutorials mod fine! It should be one of these three:

Admin CP > Templates > Modify/Delete > Global Templates Expand > tuts_index

Admin CP > Templates > Modify/Delete > *template set expand* > Tutorial Mods Expand > tuts_index

Admin CP > Templates > Modify/Delete > *template set expand* > Custom Templates Expand > tuts_index
Thanks, I found it in Global!