Hardcode a custom render view

Permalink 1 user found helpful
The client wants a blog block in the footer of every page. I got it to work by hard coding it no problem, but then I needed to use a custom view to meet their design needs, so I created a view.php and view.css in /blocks/rss_displayer/templates/bullet_date/ but by using the following code below, it won't render with my custom view.

<?php
$rd = BlockType::getByHandle('rss_displayer');
$rd->controller->itemsToDisplay = '2';
$rd->controller->url = 'http://blog.alfredapp.com/feed/'; //just using this URL for testing purposes
$rd->render('bullet_date');?>
?>


I've tried a million different things in the $rd->render part, but it either just shows the default view or gives me a file not found error.

Just for fun, I created a rss_displayer block the "old fashioned" way and when I went to use a custom template, my "Bullet Date" template was in the drop down and displayed like I wanted.
CWSpear
View Replies:
SVijay replied on at Permalink Reply
SVijay
Hi,

If you want a blog block in the footer of every page, follow the below given points

1. Log in as admin of your concrete5 installation.
2. Open ‘Dashboard’.
3. Go to Pages and themes --> Page Types section.
4. Click on ‘Defaults’ button of the necessary page type.
5. Concrete5 will redirect you to the page where you can get into editing mode and add blocks in the footer area, that you want to be created on the page type of every page by default.
6. You can also set default permissions the same way.
7. Once you exit editing mode and click ‘Publish changes’, default settings will be applied and every time you create a new page with that page type, it will have pre-defined set of blocks and permissions.
gilshwartz replied on at Permalink Reply
I know a long time has passed, but since I was struggling with a similar problem, I think it's worth having the solution here. In my case, I needed to add the 'view' basename of the 'view.php' file that renders the output.

I.E. if the template is called 'bullet_date' (directory name) and it is located in the 'templates' directory of the block, it is supposed to have something like 'view.php' file in it, which renders the block's content. In order to programatically render the block using this template you should:

...
$rd->render('templates/bullet_date/view');


C5 will add the '.php' suffix by itself. This has worked fine for me.
cartersch replied on at Permalink Reply
cartersch
This is exactly what I was looking for. I kept trying it without the 'view' at the end. Thanks for posting the solution