Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Hi, I am trying to implement extended comments using DBFs for my site. I am using the following code, which works well. However, I would like for logged in users to only see the comment form with the email and names automatically collected from their profile. I have tried everything I can but still not getting it. I sincerely hope someone will be able to help.



<cms:form id='comment_form' masterpage='comments.php' method='post' mode='create' name='comment_form'>
<cms:if k_success>
<cms:if frm_reply>
<cms:pages id=frm_reply limit='1' masterpage='comments.php'>
<cms:if comment_blog_post == "<cms:related_pages field='blog_post' ids_only='1'/>">
<cms:set comment_level='0' scope='global'/>

<cms:embed 'comment-level.php'/>

<cms:if comment_level lt comment_level_max>
<cms:set valid_parent_comment='1' scope='global'/>
</cms:if>
</cms:if>
</cms:pages>
</cms:if>

<cms:db_persist_form
_auto_title = '1'

blog_post = k_page_id
parent_comment = "<cms:if valid_parent_comment><cms:show frm_reply/></cms:if>"
status = "<cms:if k_user_access_level ge '1'>1<cms:else/>0</cms:if>"
/>

<cms:if k_error>
<div class="alert alert-danger">
<strong>Could not post comment!</strong><br/>
The following error(s) occured while processing your comment:<br/>

<ul>
<cms:each k_error>
<li><cms:show item/></li>
</cms:each>
</ul>
</div>
<cms:else/>
<cms:if k_user_access_level ge '1'>
<cms:redirect "<cms:show k_page_link/>#comment-<cms:show k_last_insert_id/>"/>
</cms:if>

<div class="alert alert-success">
<strong>Thank you for the feedback!</strong><br/>
Your comment will be published as soon as it has been reviewed by a moderator.
</div>
</cms:if>
<cms:else/>
<cms:if k_error>
<br/>

<div class="alert alert-danger">
<strong>Field(s) incomplete!</strong><br/>

<ul>
<cms:each k_error>
<li><cms:show item/></li>
</cms:each>
</ul>
</div>
</cms:if>
</cms:if>

<div class="form-group<cms:if k_error_author_name> has-error</cms:if>">
<label class="control-label" for="f_author_name">Name *</label><br/>
<cms:input class='form-control' name='author_name' style='width:50%;' type='bound'/>
</div>

<div class="form-group<cms:if k_error_author_email> has-error</cms:if>">
<label class="control-label" for="f_author_email">Email Address *</label><br/>
<cms:input class='form-control' name='author_email' style='width:50%;' type='bound'/>
</div>

<div class="form-group<cms:if k_error_comment> has-error</cms:if>">
<label class="control-label" for="f_comment">Comment *</label><br/>
<cms:input class='form-control' name='comment' style='width:100%;' type='bound'/>
</div>

<cms:input label='Parent Comment' name='reply' style='display:none;' type='text' validator='non_zero_integer'/>

<input class="btn btn-lg btn-primary"<cms:if k_success> disabled</cms:if> type="submit" value="Submit"/>
</cms:form>
I am posting your script with proper indentation. People tend to ignore unformatted code walls, so you have more chance of help with this -
Code: Select all
<cms:form id='comment_form' masterpage='comments.php' method='post' mode='create' name='comment_form'>
    <cms:if k_success>
        <cms:if frm_reply>
            <cms:pages id=frm_reply limit='1' masterpage='comments.php'>
                <cms:if comment_blog_post=="<cms:related_pages field='blog_post' ids_only='1'/>">
                    <cms:set comment_level='0' scope='global' />

                    <cms:embed 'comment-level.php' />

                    <cms:if comment_level lt comment_level_max>
                        <cms:set valid_parent_comment='1' scope='global' />
                    </cms:if>
                </cms:if>
            </cms:pages>
        </cms:if>

        <cms:db_persist_form _auto_title='1' blog_post=k_page_id parent_comment="<cms:if valid_parent_comment><cms:show frm_reply/></cms:if>" status="<cms:if k_user_access_level ge '1'>1<cms:else/>0</cms:if>" />

        <cms:if k_error>
            <div class="alert alert-danger">
                <strong>Could not post comment!</strong><br />
                The following error(s) occured while processing your comment:<br />

                <ul>
                    <cms:each k_error>
                        <li>
                            <cms:show item />
                        </li>
                    </cms:each>
                </ul>
            </div>
            <cms:else />
            <cms:if k_user_access_level ge '1'>
                <cms:redirect "<cms:show k_page_link/>#comment-<cms:show k_last_insert_id/>" />
            </cms:if>

            <div class="alert alert-success">
                <strong>Thank you for the feedback!</strong><br />
                Your comment will be published as soon as it has been reviewed by a moderator.
            </div>
        </cms:if>
        <cms:else />
        <cms:if k_error>
            <br />

            <div class="alert alert-danger">
                <strong>Field(s) incomplete!</strong><br />

                <ul>
                    <cms:each k_error>
                        <li>
                            <cms:show item />
                        </li>
                    </cms:each>
                </ul>
            </div>
        </cms:if>
    </cms:if>

    <div class="form-group<cms:if k_error_author_name> has-error</cms:if>">
        <label class="control-label" for="f_author_name">Name *</label><br />
        <cms:input class='form-control' name='author_name' style='width:50%;' type='bound' />
    </div>

    <div class="form-group<cms:if k_error_author_email> has-error</cms:if>">
        <label class="control-label" for="f_author_email">Email Address *</label><br />
        <cms:input class='form-control' name='author_email' style='width:50%;' type='bound' />
    </div>

    <div class="form-group<cms:if k_error_comment> has-error</cms:if>">
        <label class="control-label" for="f_comment">Comment *</label><br />
        <cms:input class='form-control' name='comment' style='width:100%;' type='bound' />
    </div>

    <cms:input label='Parent Comment' name='reply' style='display:none;' type='text' validator='non_zero_integer' />

    <input class="btn btn-lg btn-primary" <cms:if k_success> disabled</cms:if> type="submit" value="Submit"/>
</cms:form>
Thanks @trendoman. Appreciated the code indentation as I wait for a response.
I found a solution: hard coded k_user_name and k_user_email into editable fields and it is now working as expected.
4 posts Page 1 of 1

Who is online

In total there are 8 users online :: 0 registered, 0 hidden and 8 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 8 guests