ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Comment preview link

September 10, 2011 6:39pm

Subscribe [4]
  • #1 / Sep 10, 2011 6:39pm

    James L

    40 posts

    Hello,

    Is it possible to link to the individual comment when previewing a comment?

    My guess was to try something like this with the preview parameter (where the preview has the ID of preview):

    {exp:comment:form channel="blog" preview="blog/{segment_2}/#preview"}

    Does anyone have any suggestions or can anyone explain why that doesn’t work? Thanks in advance.

  • #2 / Sep 11, 2011 8:12pm

    Sue Crocker

    26054 posts

    Hi James L, What’s in segment_2? For instance if you have a page called blog/comment_preview, do you have something on that page that is using the following code?

    <a name="preview"></a>

    Does that help?

  • #3 / Sep 12, 2011 4:54am

    James L

    40 posts

    Hi Sue,

    {segment_2} represents the entry_title. So, for example if I’m on a page like ‘/blog/entry-title’ and I want to preview a comment, I’d like to go directly to that comment, with a link like ‘/blog/entry-title/#preview’.

    I thought the preview parameter might do that but it doesn’t seem to work. Is the preview parameter not the URL you should be sent to to preview the comment, and if it is why does the /#preview (in this case) get ommitted?

  • #4 / Sep 12, 2011 1:27pm

    Mark Bowen

    12637 posts

    Hi James,

    If I’m following what you want on this correctly you want to be able to have anchors set for each comment so that once it has been posted you can move the page to that comment?

    If so then you would need to have a unique ID for each comment in your html code and then point the preview to that link.

    Does that help at all?

    Mark

  • #5 / Sep 12, 2011 2:07pm

    James L

    40 posts

    Hi Mark,

    I’m trying to link directly to the preview (which will have the anchor ‘preview’) once a preview has been requested. Let me try and clarify a bit more as maybe I’m missing something obvious here.

    I have a blog template that displays single entries, comments and a comment form. The form looks something like this:

    {exp:comment:form channel="blog" preview="blog/{segment_2}/#preview"}
    <h2>Add your comment</h2>
    <p><ul>    <br />
        <li><br />
            <label for="name">Name:</label><br />
            <input type="text" name="name" id="name" value="{name}" required /><br />
        </li><br />
        <li><br />
            <label for="email">Email:</label><br />
            <input type="email" name="email" id="email" value="{email}" required /><br />
        </li>    <br />
        <li><br />
            <label for="comment">Your comment:</label><br />
            <textarea name="comment" id="comment" rows="6" required>{comment}</textarea><br />
        </li>        <br />
        <li><br />
            <input type="submit" name="preview" value="Preview" /><br />
        </li><br />
        <li><br />
            <input type="submit" name="submit" value="Submit" /><br />
        </li>    <br />
    </ul><br />
    {/exp:comment:form}

    The template also has a comment preview tag pair to display previews, something like this:

    {exp:comment:preview}
    <h1 id="preview">Your comment preview</h1>
    <article>
        <h1>{url_as_author}, {comment_date format="%j%S %M %Y"}</h1>
        {comment}
    </article>
    {/exp:comment:preview}

    So, when someone fills out the comment form and clicks ‘Preview’, I’d expect that form to send me to this template and the h1 (in this case) with the id of ‘preview’, as that’s what I’ve set as the preview parameter.

    That doesn’t happen. What am I missing?

  • #6 / Sep 13, 2011 3:25am

    John Henry Donovan

    12339 posts

    James,

    I think your issue here might be that you have your URL title in segment 2 as opposed to segment 3 in a standard install

    Can you do the following test for me please?

    Create a new template called preview in your blog template group and add the comment preview and submission tags

    Now in your comment form change

    {exp:comment:form channel="blog" preview="blog/{segment_2}/#preview"}

    to

    {exp:comment:form channel="blog" preview="blog/preview/{segment_3}/#preview"}

    Now visit blog/preview/your_entry_url and test the preview function

    Does that make a difference?

  • #7 / Sep 14, 2011 5:57am

    James L

    40 posts

    Hi John,

    I’ve jut tried that and same problem but I’ve just noticed that the URL never changes whatever you have set in the preview parameter. So even if I have something like:

    <input type="hidden" name="URI" value="blog/entry/entry-title" />
    <input type="hidden" name="PRV" value="blog/preview/entry-title/#preview" />

    the URL stays on ‘blog/enrty/entry-title’ when previewing the comment. I’d guess what I’m trying to do can’t be done but from everyone’s response to this perhaps it can. Should this work? Does anyone have any examples of this working?

    I should also mention, my current setup is actually more like ‘/blog/entry/entry-title’, I was just trying to simplify the example.

  • #8 / Sep 14, 2011 11:35am

    James L

    40 posts

    In addition to that last post, I’ve noticed the preview parameter can be set to absolutely anything, even a made up template group. As long as there’s something written in the preview parameter, I can still see the preview as expected (apart from the URL doesn’t change).

  • #9 / Sep 15, 2011 12:42pm

    Mark Bowen

    12637 posts

    Hi James,

    I can confirm that you can’t do what you’re after here with trying to add in the #preview like that.

    I just tested and it seems to me that the preview template is loaded in on top of the main comments page as when I tried it the URL in my browser never changed. The preview comment and the form came up but the URL doesn’t change so it looks to me like this is definitely not possible here and not something built in to ExpressionEngine in order to allow this to happen.

    Could you not place the comment preview first on the page and then the form below it?

    Users would be expecting to see the preview if they clicked on preview so for usability sake I would say this would be best.

    Does that help at all?

    Thanks,

    Mark

  • #10 / Sep 15, 2011 1:03pm

    James L

    40 posts

    Thanks for testing that Mark, good to know it’s not just me.

    I do have the preview above the form but it’s underneath the related article, so unfortunately the user has to scroll down and find the preview. I’ll maybe try some kind of Ajax work around so the main page doesn’t reload. I see there’s already an add-on for that (http://devot-ee.com/add-ons/ajax-babble).

    Thanks again.

  • #11 / Sep 15, 2011 1:51pm

    Mark Bowen

    12637 posts

    Hi James,

    Ah I see now. Yes, with showing the article above it I can see where your problem would be.

    It does unfortunately look like the preview parameter will only accept certain values and so tacking on the anchor in that way doesn’t work. Please feel free to add a Feature Request for this to be added though.

    I’m going to close this thread now as it’s not technically a fault with ExpressionEngine. I hope you get something sorted soon though.

    Thanks,

    Mark

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases