Permalink 1 user found helpful
I want to be able to redirect somebody to a coupon code in my website when somebody comments on my blog. Is this possible? If so, how can I go about doing this? Thanks for the help!

View Replies:
mesuva replied on at Permalink Reply
Are you using the built in 'guestbook' block for comments?

If so, (or even if you are using a different block), you should be able to override the controller file for it, and add towards the end of the function that processes the comment:


You would create a thank you page with a message on it and the coupon code, making
sure the page is excluded from the nav, sitemap and search index.

That's as specific as I can make it without knowing more about what you are doing.
Ziggo007 replied on at Permalink Reply
Thank you for the information. I am a noob here at concrete5 and am looking to post my first website. I understand that my site has a controller file but im not sure how to directly access it. I went to my dashboard and clicked on file manager and access to directly access the codes written for my website and I am stumped on how to change the code. I can read the code directly by going into edit mode and right clicking and clicking on view source, but I can't seem to change anything in this. Could you please shed some light on how to access the controller file and directly put commands into specific blocks? I have posted from my view source where I think the code is written for my block and I would like to know exactly where to put the command you have already given me so that when somebody posts on my first blog I will be able to redirect them to another page that personally thanks them for posting and gives them a coupon code. I have only included lines 308 to 315 because im convinced this is where the new command needs to be. I'm assuming the command needs to be right after...

<input type="submit" name="Post Comment" value="Post Comment" class="button"/>

....but I'm not really sure. Where exactly should it be put in. Your help is much appreciated.

Please type the letters and numbers shown in the image.<img src="/index.php/tools/required/captcha?nocache=1325262586" alt="Captcha Code" onclick="this.src = '/index.php/tools/required/captcha?nocache='" class="ccm-captcha-image" />Click the image to see another captcha.<br/><input type="text" name="ccmCaptchaCode" class="ccm-input-captcha" /> <br/><br/>
<input type="submit" name="Post Comment" value="Post Comment" class="button"/>

<script type="text/javascript">

Thank you so much for helping again!
mesuva replied on at Permalink Reply
Ahhh, sorry, it's hard to guess what level people are at when posting replies!

With most things that talk about code, it's about copying and editing the actual php files that drive the site, not the HTML that you view when 'viewing source'.

Before I dive in with instructions, have you got access to the concrete5 files? Are you comfortable copying and editing php files? If not, we might need to come up with a 'lower tech' solution to this.
Dinamicore replied on at Permalink Reply
Hello: I will use this post as I seek similar assistance: help to redirect to a custom thank you page, or message box, whatever is best.

All I need is a message displaying "Thank you for your comment; it will we reviewd and after that published; please click on this link to return to main page."

I am using the C5 custom guestbook block.

I am familiar with PHP and able to copy and paste.

Here is the link to the page: at the end of the 3 windows show there is a block called "Escriba su comentario aquí" where the link to the guestbook fill form is located".

Please provide a written code, and where it should be written.

Many thanks.
TheRealSean replied on at Permalink Reply
There are a few methods for this

The one I tend to use is the get and set method
On a successful post I redirect to the thanks page and use a query string

Then in the view function of the controller I use
$this->set('successMessage', $this->get('thanks'));

Then in your view file
//display message
// or get message variable if set via the block
// echo $message
I'm typing this out on anipod so there may be a few mistakes
Dinamicore replied on at Permalink Reply 1 Attachment
Thank you Sean for your reply.

Evaluating, and as I am using a pop up window in "Escriba su comentario aquí" link, a simpler solution will be to relocate the guestbook thank you message, which appears at the bottom of the main guestbook page in , to make the message appear just below the comment box of guestbook form.

Make it behave the way it appears in the standard C5 form.

I already tweked the guestbook to make both the comments appear newer on top, and the comment form (they come factory set to appear at the bottom)

Will appreciate if you could help on this.

TheRealSean replied on at Permalink Reply
I am not to sure I follow completely?

Are you saying you would like the Thank You message After the form, above the submit button?

if so, by default around line 50 is the sections which deals with the response

if (isset($response)) { ?>
   <?php echo $response?>
<?php  } ?>

You would want to move that line to just before the input button,
//dont forget the opening php tag.
//if you copy the default bit its not included
 if (isset($response)) { ?>
   <?php echo $response?>
<?php  } ?>
<input type="submit" name="Post Comment" value="<?php echo t('Enviar comentario')?>" class="button"/>

I am assuming looking at your site that you have moved the form above the comments but the response bit is still at the bottom? but its that line that show the thank you message you could also wrap it in a div to help style it.
 if (isset($response)) { ?>
   <div class="response"><?php echo $response?></div>
<?php  } ?>
//then in you css, something like the following to style your response
.response { background-color:#lightyellow; display:block; padding:4px 10px;}

Dinamicore replied on at Permalink Reply 2 Attachments
Thanks Sean; you are following this completely and exactly.

I moved up, down and to the middle, the tag:

if (isset($response)) { ?>
<?php echo $response?>
<?php } ?>

Without any difference on position. Also wrapped it in div, styled the div, and no change in style.

Attach 2 files so you can see:
1. The view.php file (in txt extension to allow upload to c5 forum)
2. An image of code we presume is generated by the response tag; no any tags or ID around it?

As this post is going away from the original thread, which was to link a thank you page, earlier I opened a new post in called relocating, to invite more helpers.

Before you last response, I already had identified the same response tag you did as being the one generating the thank you message, but now I am starting to believe it might be a different tag generating the message.

Thanks again for all your help; this seemed to be an easy customization at the beginning, but now it doesn´t.

Your help on this is much appreciated.
Dinamicore replied on at Permalink Reply 1 Attachment
I had to answer myself to this one, as I realized (finally) I was modifying the view.php file, and should be modifying the custom made template (I made days ago) date_descending.php.

I followed Sean´s indications and it worked right away. Thank you very much Sean. And very sorry for my childish mistake. I guess too much code stuffing made me forget the sequence.

I attach the date_descending file (in txt extension to allow upload) to illustrate others.

And also refer a link to the forum post which indicates the procedure to inverse comments chronological order
Dinamicore replied on at Permalink Reply
One last thing Sean; I wanted to mark yours as "best answer" but there is no button for this.

If forum administrator can look at it, and provide a button, please do so.

VidalThemes replied on at Permalink Reply
You have to have started the thread to mark a best answer.
TheRealSean replied on at Permalink Reply
Glad you got it sorted :), I make those mistakes all the time and often its not until someone is standing over my shoulder that I see the mistake.