[how-to] Render Box block

Post

Posted
Rating:
Item has a rating of 5 (Liked by Jason VerhagenLiked by Adam EdingtonLiked by Chris Graham)
#504 (In Topic #106)
Avatar
Site director
Patrick Schmalstig is in the usergroup ‘Administrators’

In this tutorial, I will show you how to make a simple block which can create/render a box of virtually any kind of Composr content via. meta_aware hooks.

Difficulty to implement: Easy
Difficulty to use: Easy-moderate

Implementation


sources_custom/blocks/main_render_box.php

Include the following in the file:

Code (php)

<?php
class Block_main_render_box
{
    public function info()
    {
        $info = array();
        $info[&#39;author&#39;] = &#39;Patrick Schmalstig&#39;;
        $info[&#39;organisation&#39;] = &#39;The Lovinity Community+&#39;;
        $info[&#39;hacked_by&#39;] = null;
        $info[&#39;hack_version&#39;] = null;
        $info[&#39;version&#39;] = 1;
        $info[&#39;locked&#39;] = false;
        $info[&#39;parameters&#39;] = array(&#39;content_type&#39;,&#39;content_id&#39;);
        return $info;
    }

    public function run($map)
    {
        i_solemnly_declare(I_UNDERSTAND_SQL_INJECTION | I_UNDERSTAND_XSS | I_UNDERSTAND_PATH_INJECTION);
        require_code(&#39;content&#39;);
        $ob=get_content_object($map[&#39;content_type&#39;]);
        list($content_title, $poster_id, $cma_info, $content_row, $content_url) = content_get_details($map[&#39;content_type&#39;], $map[&#39;content_id&#39;]);
        return $ob->run($content_row, get_module_zone($cma_info[&#39;module&#39;]));
    }
}
?>


Save.

Usage

To use, simply "add block" in your content, find the Main Blocks, Misc section, and click Render Box.

You will need to fill in content type and content ID fields.

Content type related to the content meta_aware hook name found in sources[_custom]/hooks/systems/content_meta_aware . For example, if you're rendering a forum topic, the type is topic. Forum post is type post. Comcode page type is comcode_page . Wiki+ page type is wiki_page . And so on.

Content ID is the ID of the item you're rendering. For forum post, it's the post ID #. For topic, it's the topic ID number. And so on. You may need to do a little searching to find it.

Demo

To see this in action, go to https://lovinity.org/news/view/front-page/the-lovinity-community-7?select=8&amp;blog=0

Last edit: by Chris Graham


  • Need support for version 10? The core development team is no-longer offering it for free (unless it's a critical bug that breaks your entire site or a serious security hole). Please consider hiring me instead if you need v10 support or a non-critical bug fix. Or, ask the community in the forums!
  • Do you enjoy Composr? Please consider contributing your talent to the project or recommending Composr to others. Even small contributions make a big impact in the Composr community.
  • Do you have feedback for us? You can report bugs, suggest features, or give feedback on the Free support options page.
  • Do you need professional service with your Composr website? Please consider contracting me for your needs through my company, PDStig, LLC. Doing so will also help fund Composr development.
  • Want to watch live streams of me developing Composr CMS? Please subscribe to me on Twitch to be notified when I stream. Composr development streams are usually spontaneous / not scheduled in advance as work priorities come first.
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Forum statistics:
  • 2,052 topics, 7,195 posts, 10,827 members
  • Our newest member is LowfareMart
Back to Top