Jonathan Zapata
Jonathan Zapata

Reputation: 1

Custom comments template in BlogEngine

When someone wants to write a comment, It has to set Name, Email, Web Site and finally comments . How should I modify this template to use just the Comment? Because It has these info when admin registered him. I dont want to store false info.

Thanks for your help.

Upvotes: 0

Views: 205

Answers (1)

leemicw
leemicw

Reputation: 801

Since you didn't specify the version I am assuming you are running on the current latest (3.1).

The comment submission form is controlled by the CommentForm.cshtml in the siteroot/Custom/Theme/YourCurrentTheme folder. Here is a portion of the form from the Garland-Revisited theme.

<p>
    <label for="txtName" class="lbl-user">@Resources.labels.name *</label>
    <input type="text" class="txt-user" name="txtName" id="txtName" />
</p>
<p>
    <label for="txtEmail" class="lbl-email">@Resources.labels.email *</label>
    <input type="text" class="txt-email" id="txtEmail" />
</p>
<p id="commentCompose">
    <textarea class="txt-content" id="txtContent" cols="50" rows="10" name="txtContent"></textarea>
</p>

The simplest path is probably to avoid changing the submission handler and convert the input type to hidden and prefill the value with their logged in credentials. A possible sample.

<input type="hidden" id="txtName" value="@SomeC#CodeToReadTheValuesFromTheLoggedInInformation" />
<input type="hidden" id="txtEmail" value="@SomeC#CodeToReadTheValuesFromTheLoggedInInformation" />
<p id="commentCompose">
    <textarea class="txt-content" id="txtContent" cols="50" rows="10" name="txtContent"></textarea>
</p>

This does have security implications. You are trusting your users not to mess with the hidden values in the form. On an open website this probably isn't safe enough and you will have to look at changing the submit handler.

Changing the submit handler does have its own maintenance issues since you will be running a custom version of the software that won't upgrade cleanly when the next version comes out. It's up to you to decide what is the better path in your situation.

Upvotes: 1

Related Questions