Guestbook/comments hardcode into pagetype

Permalink
Hi There,

I hope someone can help me?
I'm trying to hardcode guestbook/comments into a blog pagetype that I created. I followed these instructions and they don't seem to work:
http://www.concrete5.org/documentation/how-tos/developers/hardcode-...

I don't know if its because there isn't a scrapbook anymore? I copied the comments block to clipboard, but it still doesn't show up hardcoded when I create a new page with that specific pagetype.

Any help would be much appreciated.

junebird
View Replies: View Best Answer
hutman replied on at Permalink Best Answer Reply
hutman
There are two ways that you can go about doing this. You can either put the block into the Page Type Defaults in the place that you want it to display. Or you can hard code it in your page type. To hard code it into your page type you need to put this code where you would like the block to display:
$comments = BlockType::getByHandle('autonav');
$comments->controller->requireApproval = 0;
$comments->controller->title = 'Comments';
$comments->controller->dateFormat = 'm/d/Y';
$comments->controller->displayGuestBookForm = 1;
$comments->controller->displayCaptcha = 0;
$comments->controller->authenticationRequired = 0;
$comments->controller->notifyEmail = [email protected]';
$comments->render('view');


Note: Option 2 cannot be done through the CMS, you need to open the PHP file for your Page Type and put this code where you want it to display on the page.
junebird replied on at Permalink Reply 2 Attachments
junebird
I hardcoded the page type using the code you gave, I changed autonav to guestbook and added the captcha etc.

It worked perfectly thank you so much!

Now I just have one more question if you could help me?
I went and changed the view css for guestbook within the concrete/blocks directory.

The changes don't display on the hardcoded guestbook, unless I go and add another guestbook to the same page, then the css changes show, but the moment I delete that extra guestbook again, it goes back to the old look.

I attached pictures to show you.
In guestbook after you can see the css go live if I add another guestbook to the main content area above it.

Any advice?
hutman replied on at Permalink Reply
hutman
After you made the changes to the CSS did you clear the cache? Because this block is now part of your page type it will cache just like page content.
junebird replied on at Permalink Reply
junebird
I did sadly, and f5'd a few times for good meassure too, but no change.
hutman replied on at Permalink Reply
hutman
This is a weird quirk with hard coding blocks that I totally forgot about, they don't use their view.css. So, what you will need to do is either manually include the stylesheet file for this page type or copy/paste the CSS from the view.css into the view.php within a <style> tag.
junebird replied on at Permalink Reply
junebird
Thank you so much!
It works perfectly now!

Your advice and direction has been so helpful!!!