Welcome Guest, Not a member yet? Register   Sign In
Tutorial in docs has errors, or?

(This post was last modified: 09-04-2020, 03:44 AM by blaasvaer.)

I've been monkeying through the tutorial in the docs:

to get my head around this 'new' version.

In this part:

At the bottom of the paragraph titled "Display the news" I see this:
<h2><?= esc($news['title']); ?></h2>
<?= esc($news['body']); ?>

Now, this throws and error in my case:
Undefined index: title

So, in order to correct this I rewrite the above part to this:
<h2><?= $title; ?></h2>
<? // = esc($news['body']); ?>

If you notice, I commented out the 'body' part as it throws the same error (undefined variable) and I can't seem to see that a 'body' is actually passed into the view anywhere?

What part is it that I completely missed in the process? Remember there is the index method and the view method … defined in the Routes.php. Could it be that somewhere along the tutorial something was missed, or did I just totally screw it all up by myself (yeah, good boy there)?

Yep, and as soon as I posted this ... I found the answer.

I had mistyped
echo view('templates/header', $data);
echo view('news/view', $data);
echo view('templates/footer', $data);

instead of this:

echo view('templates/header', $data);
echo view('news/overview', $data);
echo view('templates/footer', $data);

In my index method (note the missing 'over' in overview … ).

Note to self: use copy/paste when following tutorials ...

Rule of life: if you've banged your head against something for a while ... write a post in a forum somewhere (it probably doesn't matter which one) and boom, there's your answer.

well i'm a Slackware Linux user i.e a Slacker and even i don't like that coding lazyness for goodness sake you save a couple of chars with abomination abbreviation. Best thing is pretend you ddon't see it.

As for the rest of the documentation, I read it, implemented it and my web is working . So the moral of the story is ..

Theme © iAndrew 2016 - Forum software by © MyBB