Open asani opened 9 years ago
Hey asani, Are you using jquery to trigger the active state? You will need to provide more information about your problem. If you post some code, I will be happy to take a look and see if it's something I can answer for you.
Great thanks....witch code do you need to see? im kind a lost and just keep on with the videos...but i guess you want the js.php and the navigation.php so:
navigation.php:
<h1>Navigation</h1>
<div class="row">
<div class="col-md-3">
<ul id="sort-nav" class="list-group">
<?php
$q = "SELECT * FROM navigation ORDER BY position ASC";
$r = mysqli_query($dbc, $q);
while ($list = mysqli_fetch_assoc($r)) { ?>
<li class="list-group-item"><?php echo $list['label']; ?></li>
<?php } ?>
</ul>
</div>
<div class="col-md-9">
<?php if(isset($message)) { echo $message; }?>
<?php $q = "SELECT * FROM navigation ORDER BY position ASC";
$r = mysqli_query($dbc, $q);
while($opened = mysqli_fetch_assoc($r)) { ?>
<form class="form-inline" action="index.php?page=navigation&id=<?php echo $opened['id']; ?>" method="post" role="form">
<div class="form-group">
<label class="sr-only" for="id">ID:</label>
<input class="form-control" type="text" name="id" id="id" value="<?php echo $opened['id']; ?>" placeholder="Id-name" autocomplete="off">
</div>
<div class="form-group">
<label class="sr-only" for="label">Label:</label>
<input class="form-control" type="text" name="label" id="label" value="<?php echo $opened['label']; ?>" placeholder="Label" autocomplete="off">
</div>
<div class="form-group">
<label class="sr-only" for="url">URL:</label>
<input class="form-control" type="text" name="url" id="url" value="<?php echo $opened['url']; ?>" placeholder="URL" autocomplete="off">
</div>
<div class="form-group">
<label class="sr-only" for="position">Position:</label>
<input class="form-control" type="text" name="position" id="position" value="<?php echo $opened['position']; ?>" placeholder="" autocomplete="off">
</div>
<div class="form-group">
<label class="sr-only" for="status">Status:</label>
<input class="form-control" type="text" name="status" id="status" value="<?php echo $opened['status']; ?>" placeholder="" autocomplete="off">
</div>
<button type="submit" class="btn btn-default">Save</button>
<input type="hidden" name="submitted" value="1">
<input type="hidden" name="openedid" value="<?php echo $opened['id']; ?>">
</form>
<?php }?>
</div>
</div><!-------END CONTAINER FLUID---->
and js.php:
<?php
// Javascript:
?>
and the query.php for good mesure:
<?php
switch ($page) {
case 'dashboard':
break;
case 'pages':
if(isset($_POST['submitted']) == 1) {
/*
$title = mysqli_real_escape_string($dbc, $_POST['title']);
$header = mysqli_real_escape_string($dbc, $_POST['header']);
$body = mysqli_real_escape_string($dbc, $_POST['body']);
*/
$title = $_POST['title'];
$header = $_POST['header'];
$body = $_POST['body'];
if (isset($_POST['id']) && $_POST['id'] != '') {
$action = 'updated';
$q = "UPDATE pages SET user = $_POST[user], slug = '$_POST[slug]', title = '$title', header = '$header', body = '$body' WHERE id = $_GET[id]";
} else {
$action = 'added';
$q = "INSERT INTO pages (user, slug, title, header, body) VALUES ($_POST[user], '$_POST[slug]', '$title', '$header', '$body')";
}
$r = mysqli_query($dbc, $q);
if($r){
$message = '<P class="alert alert-success">Page was '.$action.'!</p>';
} else{
$message = '<p class="alert alert-danger">Page could not be '.$action.' because: '.mysqli_error($dbc);
$message .= '<p class="alert alert-warning">Query: '.$q.'</p>';
}
}
if(isset($_GET['id'])) { $opened = data_page($dbc, $_GET['id']); }
break;
case 'users':
if(isset($_POST['submitted']) == 1) {
/*
$first = mysqli_real_escape_string($dbc, $_POST['first']);
$last = mysqli_real_escape_string($dbc, $_POST['last']);
*/
$first = $_POST['first'];
$last = $_POST['last'];
if($_POST['password']!= '') {
if($_POST['password'] == $_POST['passwordv']) {
$password = " password = SHA1('$_POST[password]'),";
$verify = true;
} else {
$verify = false;
}
} else {
$verify = false;
}
if (isset($_POST['id']) && $_POST['id'] != '') {
$action = 'updated';
$q = "UPDATE users SET first = '$first', last = '$last', email = '$_POST[email]', $password status = $_POST[status] WHERE id = $_GET[id]";
$r = mysqli_query($dbc, $q);
} else {
$action = 'added';
$q = "INSERT INTO users (first, last, email, password, status) VALUES ('$first', '$last', '$_POST[email]', SHA1('$_POST[password]'), '$_POST[status]')";
if($verify == true) {
$r = mysqli_query($dbc, $q);
}
}
if($r){
$message = '<P class="alert alert-success">User was '.$action.'!</p>';
} else{
$message = '<p class="alert alert-danger">User could not be '.$action.' because: '.mysqli_error($dbc);
if($verify == false) {
$message .= '<p class="alert alert-danger">Password fields empty or do not match.</p>';
}
$message .= '<p class="alert alert-warning">Query: '.$q.'</p>';
}
}
if(isset($_GET['id'])) { $opened = data_user($dbc, $_GET['id']); }
break;
case 'navigation':
if(isset($_POST['submitted']) == 1) {
/*$first = mysqli_real_escape_string($dbc, $_POST['first']);
$last = mysqli_real_escape_string($dbc, $_POST['last']);*/
$label = $_POST['label'];
$url = $_POST['url'];
if (isset($_POST['id']) && $_POST['id'] != '') {
$action = 'updated';
$q = "UPDATE navigation SET id = '$_POST[id]', label = '$label', url = '$url', position = $_POST[position], status = $_POST[status] WHERE id = '$_POST[openedid]'";
$r = mysqli_query($dbc, $q);
}
if($r){
$message = '<P class="alert alert-success">Navigation Item was '.$action.'!</p>';
} else{
$message = '<p class="alert alert-danger">Navigation Item could not be '.$action.' because: '.mysqli_error($dbc);
$message .= '<p class="alert alert-warning">Query:'.$q.'</p>';
}
}
break;
case 'settings':
if(isset($_POST['submitted']) == 1) {
/*$first = mysqli_real_escape_string($dbc, $_POST['first']);
$last = mysqli_real_escape_string($dbc, $_POST['last']);*/
$label = $_POST['label'];
$value = $_POST['value'];
if (isset($_POST['id']) && $_POST['id'] != '') {
$action = 'updated';
$q = "UPDATE settings SET id = '$_POST[id]', label = '$label', value = '$value' WHERE id = '$_POST[openedid]'";
$r = mysqli_query($dbc, $q);
}
if($r){
$message = '<P class="alert alert-success">Setting was '.$action.'!</p>';
} else{
$message = '<p class="alert alert-danger">Setting could not be '.$action.' because: '.mysqli_error($dbc);
$message .= '<p class="alert alert-warning">Query:'.$q.'</p>';
}
}
break;
default:
break;
}
?>
by the way im at video/part 89 now and thats why i have more code to the php files
I think the file you need to look at is /functions/template.php
I do not see anything in your js.php
https://github.com/thedigicraft/Atom.CMS/blob/master/config/js.php https://github.com/thedigicraft/Atom.CMS/blob/master/functions/template.php
i cant seem to find anything wrong with it...:
check it out...iv rechecked like 10 times
this is what i have in the template.php
<?php
function nav_main($dbc, $pageid){
$q = "SELECT * FROM pages";
$r = mysqli_query($dbc, $q);
while($nav = mysqli_fetch_assoc($r)){ ?>
<li<?php if($pageid == $nav['id']){ echo ' class="active"'; }?>><a href="?page=<?php echo $nav['id']; ?>"><?php echo $nav['title']; ?></a></li>
<?php }
}
?>
i guess alan reforms the code later on because my function/template.php is totally different...i dont want to copy it so as not to mess up my rythme...or have i lost it? :)
thanks for your time man i appreciate it!!
Are you following the 2014 series?
Video 85 at around 3:30 he edits template.php and doesn't look anything like yours.
https://www.youtube.com/watch?v=E4CVj2uW3Ys&index=85&list=PLAkMqlQoeMeiwvNWpe3mhgQxAa1jiGwmt
yeah i think i am...didnt even know there was a 2015....fuck....have i like wasted a week on this?? :( well the change must have slipped by me...if i change the code now will it effect the rest of the code...i mean he must have change other properties!! :(
i actually have seen video 85 and i just now saw that i had $pageid instead of $path on top...but i teated it and i got this error on the front end.:
Fatal error: Cannot use string offset as an array in /home/a9667120/public_html/functions/template.php on line 16
the back end still functions as it should!1 wtf?? :)
sorry man i think i gave you a wrong code erlier...this is what i have on the functions/template.php on the front end:
<?php
function nav_main($dbc, $pageid){
$q = "SELECT * FROM navigation ORDER BY position ASC";
$r = mysqli_query($dbc, $q);
while($nav = mysqli_fetch_assoc($r)){
$nav['slug'] = get_slug($dbc, $nav['url']);
?>
<li<?php selected($path['call_parts'][0], $nav['slug'], 'class="active"') ?>><a href="<?php echo $nav['url']; ?>"><?php echo $nav['label']; ?></a></li>
<?php }
}
?>
as soon as i change
function nav_main($dbc, $pageid)
to
function nav_main($dbc, $path)
i get this error on the front end:
Fatal error: Cannot use string offset as an array in /home/a9667120/public_html/functions/template.php on line 16
by the way i cant seem to find the 2015 series....does it atchally continue with this code???
Im on part 40 something cuz ive had to reatart like 4 times. I might be wrong on this one but y do u have two brackets <?php } } ?> ? Somethin about that seems off. Again i could be wrong but..
--- Original Message ---
From: "asani" notifications@github.com Sent: May 29, 2015 7:22 PM To: "thedigicraft/Atom.CMS" Atom.CMS@noreply.github.com Subject: Re: [Atom.CMS] Part-84 Nav active not displaying (#129)
sorry man i think i gave you a wrong code erlier...this is what i have on the functions/template.php on the front end:
<?php
function nav_main($dbc, $pageid){
$q = "SELECT * FROM navigation ORDER BY position ASC";
$r = mysqli_query($dbc, $q);
while($nav = mysqli_fetch_assoc($r)){
$nav['slug'] = get_slug($dbc, $nav['url']);
?>
<li<?php selected($path['call_parts'][0], $nav['slug'], 'class="active"') ?>><a href="<?php echo $nav['url']; ?>"><?php echo $nav['label']; ?></a></li>
<?php }
}
?>
Reply to this email directly or view it on GitHub: https://github.com/thedigicraft/Atom.CMS/issues/129#issuecomment-106966344
thanks for the tip man, anything is something but that extra bracket is part of the }?>
from another <?php tag...so not right dude...itlooks kinda weird but so does everything else on my code...but thax man...
if i remove it i get a syntax error...but hey maybe the <?php tag somewhere in the code also is misplaced...
Try taking out the <?php and leave } } ?>
--- Original Message ---
From: "asani" notifications@github.com Sent: May 29, 2015 8:35 PM To: "thedigicraft/Atom.CMS" Atom.CMS@noreply.github.com Cc: "Chriswilldo" christophil@hotmail.com Subject: Re: [Atom.CMS] Part-84 Nav active not displaying (#129)
if i remove it i get a syntax error...but hey maybe the <?php tag somewhere in the code also is misplaced...
Reply to this email directly or view it on GitHub: https://github.com/thedigicraft/Atom.CMS/issues/129#issuecomment-106971141
Sorry id be able to help u better if i was where u were
--- Original Message ---
From: "asani" notifications@github.com Sent: May 29, 2015 8:35 PM To: "thedigicraft/Atom.CMS" Atom.CMS@noreply.github.com Cc: "Chriswilldo" christophil@hotmail.com Subject: Re: [Atom.CMS] Part-84 Nav active not displaying (#129)
if i remove it i get a syntax error...but hey maybe the <?php tag somewhere in the code also is misplaced...
Reply to this email directly or view it on GitHub: https://github.com/thedigicraft/Atom.CMS/issues/129#issuecomment-106971141
hi guys i have an issue where the active state does not display...everything is good for the rest but the active state is not working...where did i go wrong??