Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

PHP Code

edited May 2012 in Framework

When I am in the page editor section of the site...is there a special way to paste php code in there? Or can I past php code in there and have it process? I want to design a page layout say in dreamweaver and then paste the result in there...is that possible? Or will it render it useless?

Thanks

Comments

  • To execute PHP code, you'll need to create a "handler" which just means a script in an Elefant app. Then you'll need to add it to the dynamic objects menu. It's actually pretty easy to do though, here's all you need:

    1. Save this to apps/myapp/handlers/hello.php:

    <?php echo '<p>Hello world</p>'; ?>
    

    2. Save this to apps/myapp/conf/embed.php:

    ; <?php /*
    
    [myapp/hello]
    label = "MyApp: Hello world"
    
    ; */ ?>
    

    Now you'll see the "MyApp: Hello world" under the Dynamic Objects menu, and if you add it to your page, it'll add a <p>Hello world</p> where it was inserted. You can see an app is really just a folder structure to keep related PHP scripts well organized.

    You can embed any JavaScript or HTML into a page via the "Embed HTML Code" dynamic object, but not PHP.

  • edited May 2012

    Okay...so if I want to say put the lower half of a page to look like 6 images with text underneath...i can create a folder under apps called....pic_display...then in handlers...name it display.php....put in my code....then do the rest of what you said. Right? I realize I can do the HTML code...but that would be too easy right? I need to learn how the cms functions.

  • I did as you said but it doesn't show in Dynamic Objects. I created a folder in apps and titled it what I wanted and then made the reference equal what the php file is called in the handlers folder and also in the embed file too.

  • Try working from the two exact files above and see if that's working, since those work for me here. Then change the names and see where it stops working. That should help track down where yours is different from the working code.

  • Tried that and same result. I created a folder in apps called myapp...within myapp, I created 2 folders called handlers and conf. I placed the hello.php in the handlers folder and embed.php in the conf folder.

  • Hmm, that's strange. It definitely appears for me, but it is on the second page of the list in the dynamic objects dialog.

  • I went through all 4 pages. It is strange.

  • What version of Elefant do you have there?

  • edited May 2012

    The latest from github...the beta that you had fixed the default/index page issue when selecting templates. Says 1.3.1

  • Hmm... scratching my head a bit then. Any chance this is on a site I can see somewhere? :)

  • I can see that the myapp/hello handler is working, but I'll need a login to see any more. You can email me at johnny-at-johnnybroadway.com

  • Yeah I saw that too. It displays but something I think is up with the embed

Sign In or Register to comment.