SimoneS93 / anchorCMS

Object-oriented addons for AnchorCMS
1 stars 0 forks source link

Get "Uncaught Exception" #1

Open cypherpunks1 opened 10 years ago

cypherpunks1 commented 10 years ago

Hello. I try use you library (ooanchor) in my project. Unfortunately i get this error:

Invalid argument supplied for foreach()

Origin

themes/givenchybeauty.ru/ooanchor.php on line 309

How i can fix that? Thank you. screen shot 2014-05-27 at 1 43 46 am

SimoneS93 commented 10 years ago

Hello, first of all I'm glad you're using my little work :). I tried to figure out what may have caused the error from the trace you sent me, but with no luck. I see you got the error running "pages::get('parent_slug', 'makeup')": is it right? I've done the same in my own code, but I get no error.

Try this:

Send me what you get by "var_dump()". It'll help me helping you.

2014-05-26 23:44 GMT+02:00 cypherpunks1 notifications@github.com:

Hello. I try use you library (coanchor) in my project. Unfortunately i get a this error:

Invalid argument supplied for foreach()

Origin

themes/givenchybeauty.ru/ooanchor.php on line 309

How i can fix that? Thank you. [image: screen shot 2014-05-27 at 1 43 46 am]https://cloud.githubusercontent.com/assets/7607758/3085928/d92f979e-e51e-11e3-9b2b-7ba5c51417fd.png

— Reply to this email directly or view it on GitHubhttps://github.com/SimoneS93/anchorCMS/issues/1 .

cypherpunks1 commented 10 years ago

Thank you for you help. var_dump() is receive "NULL". What it mean?

SimoneS93 commented 10 years ago

I'm sorry, I updated the code but didn't update the readme file. You have to paste the following in "anchor/models/page.php":

    public static function listing() {
        return static::where('id', '>', -1)->get();
    }

    public static function id($id) {
        return static::where('id', '=', $id)->fetch();
    }

Now it should work

2014-05-27 23:41 GMT+02:00 cypherpunks1 notifications@github.com:

Thank you for you help. var_dump() is receive "NULL". What it mean?

— Reply to this email directly or view it on GitHubhttps://github.com/SimoneS93/anchorCMS/issues/1#issuecomment-44339348 .

SimoneS93 commented 10 years ago

I've updated the code a little, you should re-download it. Also, re-read the doc.

2014-05-28 8:27 GMT+02:00 Simone Salerno salernosimone.uni@gmail.com:

I'm sorry, I updated the code but didn't update the readme file. You have to paste the following in "anchor/models/page.php":

    public static function listing() {
        return static::where('id', '>', -1)->get();
    }

    public static function id($id) {
        return static::where('id', '=', $id)->fetch();
    }

Now it should work

2014-05-27 23:41 GMT+02:00 cypherpunks1 notifications@github.com:

Thank you for you help. var_dump() is receive "NULL". What it mean?

— Reply to this email directly or view it on GitHubhttps://github.com/SimoneS93/anchorCMS/issues/1#issuecomment-44339348 .

cypherpunks1 commented 10 years ago

Oh! Thank you! It works now. But, this is next question. I have the multilevel structure on my site. It looks like this: Category > Products family > Single Product. Can i get this structure with your framework? Sorry, i never use the php, only JS.

SimoneS93 commented 10 years ago

How do you handle this structure? With a custom field? I have the same in my own site. Since you use JS, I'll post my solution (which involves JS and uses a tab-navigation): Assume your subcategory is a custom field named 'family':

posts.php

<? if ($category = oocategories::current()): //check you're on a category page

// get all posts from current category
$posts = ooposts::match('category', $category->id);

// get all subcategories (needed for navigation)
$subcategories = array_unique(array_map(function($post) {
    return $post->family;
}, $posts));

?>

---- HTML here ----