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

blog posts menu with Icons (generated from posts image)

edited October 2012 in Design

Is it posible to generate menu that will contain image from post (scaled version) and link to post ?

Where to start ? Im totaly new in this framework. Thanks

Comments

  • Right now you'd have to make a custom handler that parses the post body for the first <img> tag and extracts the image URL. There's a function in apps/filemanager/lib/Functions.php that does the resizing part as well. Here's an example that should work:

    https://gist.github.com/3872942

    I've started working on a way to add custom fields to blog posts and other types like users too, so you'd be able to add a thumbnail field for more control. It's being tracked on Github here:

    https://github.com/jbroadway/elefant/issues/107

    Unfortunately, it'll probably be a little while before I can really sit down and finish it. But that will make it much more elegant to do things like this :)

  • Thank you for your work :) i will look on this.

  • edited March 2013

    My concept has changed but thank you - it was useful. Im making the next page on the elefantCMS, this time I have a little more complicated question. Im not making a new thread because it may already be somewhere. I was looking for I can not find it. I am also working in CakePHP and it is nicely shown how to pass variables to work with MVC how to extract data from the database 'and display them. Is there any good examples? Specifically, I need to execute page that will contain editable data and data from the blog. Something like page INDEX function in the controller "blog," but the controller pages. In other words, how to connect the controller to another controller. Or how to make a dynamic object that will show data from the blog?

  • I'm not sure if this quite answers your question, but if you want to pull data from the blog entries and output it, you would use the blog\Post object like this:

    <?php // apps/myapp/handlers/showposts.php
    
    // fetch the data from the blog\Post model
    $posts = blog\Post::query ()
        ->where ('published', 'yes')
        ->order ('ts desc')
        ->fetch (10);
    
    // pass it to the view template
    echo View::render (
        'myapp/showposts',
        array (
            'posts' => $posts
        )
    );
    
    ?>
    

    Then in your view template:

    <!-- apps/myapp/views/showposts.html -->
    <ul>
    {% foreach posts as post %}
        <li><a href="/blog/post/{{post->id}}/{{post->title|URLify::filter}}">{{post->title}}</a></li>
    {% end %}
    </ul>
    

    If you're looking to call one handler from another, you can do so like this:

    <?php
    
    echo $this->run ('blog/index');
    
    ?>
    

    That will output the main blog contents into your own handler.

Sign In or Register to comment.