thedigicraft / Atom.CMS

Atom.CMS
56 stars 52 forks source link

Navigation #136

Open SPMR01 opened 9 years ago

SPMR01 commented 9 years ago

Hi Firstly thank you for a great learning experience, I shall certainly be making a contribution.

As a silver headed newbie I have finished the videos and managed to keep up! However, when I add a page in the admin side it succeeds and the database shows the new page and it appears in the admin pages list, but the page does not appear in the admin navigation page. It does not also show in the front end either. I have checked for errors and there are none. Can anyone help me understand what I may be doing wrong? Help much appreciated. MC

creptor commented 9 years ago

At this point I'm not sure what was working at the end of the series, but I belive the navigation still needed some code.

SPMR01 commented 9 years ago

Further to creptor's comment (thanks for that) I looked at adding a muliple query to insert data to the navigation table in database.

That part of the code reads in Queries page:

                $q = "INSERT INTO posts (type, user, slug, title, label, header, body) VALUES (1, $_POST[user], '$_POST[slug]', '$title', '$label', '$header', '$body');";
                $q .= "INSERT INTO navigation (id, label, url) VALUES ('$id', '$label', '$opened' );";

                        }

            $r = mysqli_multi_query($mysqli, $r);

            if ($r) {
do {
    // grab the result of the next query
    if (($result = mysqli_store_result($mysqli)) === false && mysqli_error($mysqli) != '') {
        echo "Query failed: " . mysqli_error($mysqli);
    }
} while (mysqli_more_results($mysqli) && mysqli_next_result($mysqli)); // while there are more results

} else { echo "First query failed..." . mysqli_error($mysqli); } $r = mysqli_multi_query($dbc, $r);

The error message reads:

Page could not be added because: Query was empty

Query: INSERT INTO posts (type, user, slug, title, label, header, body) VALUES (1, 1, 'contact', 'Contact', 'contact', 'Contact Us', '');INSERT INTO navigation (id, label, url) VALUES ('', 'contact', '' );

It would therefore appear that the id and url are not posting. I used the variables that I thought would do the job, but obviously not. Can anyone point me in the right direction>

Thanks

MC

JasonMate commented 9 years ago

Isn't $opened an array?? If so you would add it to the query like this: '$opened[url]'

On Thu, Jun 25, 2015 at 7:40 AM, SPMR01 notifications@github.com wrote:

Further to creptor's comment (thanks for that) I looked at adding a muliple query to insert data to the navigation table in database.

That part of the code reads in Queries page:

            $q = "INSERT INTO posts (type, user, slug, title, label, header, body) VALUES (1, $_POST[user], '$_POST[slug]', '$title', '$label', '$header', '$body');";
            $q .= "INSERT INTO navigation (id, label, url) VALUES ('$id', '$label', '$opened' );";

                    }

        $r = mysqli_multi_query($mysqli, $r);

        if ($r) {

do { // grab the result of the next query if (($result = mysqli_store_result($mysqli)) === false && mysqli_error($mysqli) != '') { echo "Query failed: " . mysqli_error($mysqli); } } while (mysqli_more_results($mysqli) && mysqli_next_result($mysqli)); // while there are more results

} else { echo "First query failed..." . mysqli_error($mysqli); } $r = mysqli_multi_query($dbc, $r);

The error message reads:

Page could not be added because: Query was empty

Query: INSERT INTO posts (type, user, slug, title, label, header, body) VALUES (1, 1, 'contact', 'Contact', 'contact', 'Contact Us', '');INSERT INTO navigation (id, label, url) VALUES ('', 'contact', '' );

It would therefore appear that the id and url are not posting. I used the variables that I thought would do the job, but obviously not. Can anyone point me in the right direction>

Thanks

MC

— Reply to this email directly or view it on GitHub https://github.com/thedigicraft/Atom.CMS/issues/136#issuecomment-115261145 .

creptor commented 9 years ago

First you must check that the databes acepts null values, because you're sending some of them. (An id can't be null, if it's set to auto-increment and as primary key) For the id I recomend checking the code that's sending the data, and the grab process so that the variable $id has something set to it.

Chriswilldo commented 9 years ago

One thing to that I noticed, you have to create the navigation on phpmyadmin as well. Because earlier today when I was working on finishing the series, I noticed that I had a contact page in navigation, but I had a test page that only showed in page manager. Then I remembered that earlier in the series that we added home, about, and contact to our navigation in phpmyadmin. So I switched the title, label, header, etc, to contact and it worked. Try that and see how it works. I haven't finished the series yet, but I was hoping for there to be a way to add a navigation via admin navigation page. Guess I'll have to wait and see.

SPMR01 commented 9 years ago

Many thanks for responses. As a complete newcomer to this I am on a steep learning curve and I am still trying to get my head around how it works, So far I can add a page through Page Manager. Everything works. However, the page does not appear in Navigation Page nor in the front end Navigation Bar. You cannot add to the Navigation Page and when you try to change what is there, it simply overwrites the database entry. I am now going to play around with the coding bearing in mind the comments above.

Chriswilldo commented 9 years ago

No no no. You need to go to your phpmyadmin. Insert a new page in navigation. Make sure u fill out the id label url position right. Leave target n status blank. Then go to your page manager and add it. Make sense? Trust me ive tried it twice now. I just tried it again to make sure.

--- Original Message ---

From: "SPMR01" notifications@github.com Sent: June 26, 2015 2:27 AM To: "thedigicraft/Atom.CMS" Atom.CMS@noreply.github.com Cc: "Chriswilldo" christophil@hotmail.com Subject: Re: [Atom.CMS] Navigation (#136)

Many thanks for responses. As a complete newcomer to this I am on a steep learning curve and I am still trying to get my head around how it works, So far I can add a page through Page Manager. Everything works. However, the page does not appear in Navigation Page nor in the front end Navigation Bar. You cannot add to the Navigation Page and when you try to change what is there, it simply overwrites the database entry. I am now going to play around with the coding bearing in mind the comments above.


Reply to this email directly or view it on GitHub: https://github.com/thedigicraft/Atom.CMS/issues/136#issuecomment-115561033

SPMR01 commented 9 years ago

Sorry, I did not make myself clear. I have noted your comments and did what you advised and the result was as you wrote. Thank you for your guidance. I was just indicating how I was experimenting with the system to see how I could get the Page Manager to add the url etc. to the Navigation Page and thus to the front end. As an excited Newbie I may be letting my enthusiasm run away with me! Just one thing though, would it not be more economical to combine the Navigation Page with the Page Manager and have the ability to sort included in the list on the left hand side?

Chriswilldo commented 9 years ago

Yeah i guess you could if you wanted to. Although im not sure how to do that off the top of my head. I'd have to look at the coding. Only thig is that the coding end might get messy.

--- Original Message ---

From: "SPMR01" notifications@github.com Sent: June 26, 2015 3:08 AM To: "thedigicraft/Atom.CMS" Atom.CMS@noreply.github.com Cc: "Chriswilldo" christophil@hotmail.com Subject: Re: [Atom.CMS] Navigation (#136)

Sorry, I did not make myself clear. I have noted your comments and did what you advised and the result was as you wrote. Thank you for your guidance. I was just indicating how I was experimenting with the system to see how I could get the Page Manager to add the url etc. to the Navigation Page and thus to the front end. As an excited Newbie I may be letting my enthusiasm run away with me! Just one thing though, would it not be more economical to combine the Navigation Page with the Page Manager and have the ability to sort included in the list on the left hand side?


Reply to this email directly or view it on GitHub: https://github.com/thedigicraft/Atom.CMS/issues/136#issuecomment-115568095

SPMR01 commented 9 years ago

Hi again. Just to update my learning experiments. I have added two form elements in the Page Manager - Position and URL. I then added the position I wanted and the full url of each page. Adjusting the Queries updated and Inserted fields completed the update of the DB perfectly. Then in front end Template I changed: $q = "SELECT * FROM navigation ORDER BY position ASC"; to $q = "SELECT * FROM posts ORDER BY position ASC";

This then gave the right information to the front end index page. This then ignores the Navigation Page.

The trick now will be to get the Page Manager list to be given that cool 'list-sort' effect. Really appreciate this opportunity to develop skills. Many thanks.