single entry comment form on homepage
Posted: 12 October 2007 04:31 AM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  72
Joined  06-06-2007

I purchased EE Personal back in July and have just gotten around to using it to create version 2 of my personal site. I’ve done 90% my templates, and the pages are looking sweet! But ... after 2 days of banging my head against the wall, i cant figure out how to achieve a specific layout I am looking for.

My homepage does not mimic a typical blog layout. I do not want to list the 10 most recent posts, I want to list only one. I’ve done this already ... but I also want to include the comment form for this single post on this page like i would on any other single entry page.

My homepage URL however will obviously not include the url title for the most recent post. It will look more like…

http://www.domain.com/

How can I achieve this?

I have read a number of posts in the forums on this topic, everyone so far has said it can’t be done. That comment form tags dont work embedded in web entry tags, and that its near impossible to pass the entry_id from the web entries tag to the comment form tag dependably due to the way templates get rendered.

This is not an option for me. I would really appreciate some ideas on how to pull this off. Perhaps a dynamic redirect to a real single entry page? I would love to hear you ideas. I hope I am able to find a solution, EE is very impressive so far otherwise.

*begins begging*

 Signature 

Mac Pro 4x3ghz, 1.8TB HD, 4G RAM, Dual 20” Screens in the house ... *drool*

Profile
 
 
Posted: 12 October 2007 07:10 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  319
Joined  06-14-2006

One way would be to use limit=“1” as a parameter to exp:weblog;entries. Or you can use entry_id=“whatever”, perhaps dynamically deriving a value for “whatever”. Then there’s dynamic=“off” which might help you.

Plenty of options; what makes sense depends on the overall design.

Profile
 
 
Posted: 12 October 2007 11:37 AM   [ Ignore ]   [ # 2 ]  
Grad Student
Avatar
Rank
Total Posts:  72
Joined  06-06-2007

I believe you misread, my apologies for not being clear enough. I’ve already tackled the code for showing the single post on the page ... using limit=“1”, orderby ... etc ... thats not a problem at the moment.

The problem is displaying the comment form underneath the post, and on the homepage which since its not a real “single entry” page does not have the URL title or ID to go from.

again, the url is ...

ttp://www.domain.com/

and NOT ..

ttp://www.domain.com/blog/some_specific_post_title_or_id

 Signature 

Mac Pro 4x3ghz, 1.8TB HD, 4G RAM, Dual 20” Screens in the house ... *drool*

Profile
 
 
Posted: 12 October 2007 12:22 PM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  319
Joined  06-14-2006

If you can nest exp:comment:entries within exp:weblog:entries, all you need to do is to pass the weblog entry’s entry_id as a parameter to exp:comment:entries. And of course add all the necessary code to the index template.

If you can’t nest, you’ll have to find a way to preserve entry_id between the two tags. I’m pretty sure that a simple assign_variable won’t work because of parsing order issues, but there’s probably a few lines of PHP code that’ll do the stashing and retrieving.

There may be an even better way, but I can’t think of anything right now. It’s not something I’ve ever done.

Profile
 
 
Posted: 12 October 2007 12:26 PM   [ Ignore ]   [ # 4 ]  
Moderator
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  32911
Joined  05-14-2004

You might like to try Comments on Index =)

 Signature 
Profile
MSG
 
 
Posted: 12 October 2007 12:33 PM   [ Ignore ]   [ # 5 ]  
Grad Student
Avatar
Rank
Total Posts:  72
Joined  06-06-2007

@markus - you’re thinking along the right lines, I tried all of those options already. The option of greatest hope is the one that Lisa mentioned.

@lisa - I will give another try with that method, last night I had no luck with it. I could indeed set the entry ID as a php var within the weblog entries loop, but i was unable to get the comment entries tag to make use of that variable. Is there some trick to going from php back to EE?

I did want to ask as well lisa ... what does

“Be careful when utilizing these instructions, as this can be fairly intensive on your hosting.”

translate to mean exactly?

 Signature 

Mac Pro 4x3ghz, 1.8TB HD, 4G RAM, Dual 20” Screens in the house ... *drool*

Profile
 
 
Posted: 12 October 2007 12:40 PM   [ Ignore ]   [ # 6 ]  
Moderator
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  32911
Joined  05-14-2004

It means that when you’re showing multiple entries, and then showing all the comments for each entry, EE has to do a lot of work.  So if you’re showing 20 entries, and each of those entries has 20 comments, you could have a problem.

This is something to be aware of on a case by case basis; it is, of course, always possible for someone to customize themselves into a slow-loading site.  However, you’re limiting the scope so you should be fine.  If it does appear that things slow down considerably, then a direct query might be your best option.

 Signature 
Profile
MSG
 
 
Posted: 12 October 2007 12:44 PM   [ Ignore ]   [ # 7 ]  
Grad Student
Avatar
Rank
Total Posts:  72
Joined  06-06-2007

Thanks lisa! Trying it out now. I hope this is the last you hear from me on this topic smile

 Signature 

Mac Pro 4x3ghz, 1.8TB HD, 4G RAM, Dual 20” Screens in the house ... *drool*

Profile
 
 
Posted: 12 October 2007 12:56 PM   [ Ignore ]   [ # 8 ]  
Grad Student
Avatar
Rank
Total Posts:  72
Joined  06-06-2007

Hmmm not working ....

I have a blog/index template (set to allow php execution)

{assign_variable:my_weblog_name="myblog"}
{assign_variable
:my_template_group="blog"}

{exp
:weblog:entries weblog="{my_weblog_name}" limit="1" orderby="date" sort="desc" disable="member_data|trackbacks"}
    
<h2 class="title">{title}</h2>
    
{summary}
    {body}
    
<hr/>
    <
p>Posted by {url_or_email_as_author} on {entry_date format='%m/%d'} at {entry_date format='%h:%i %A'}</p>
    
{if allow_comments}
    
({comment_total}) <a href="{url_title_path="{my_template_group}/comments"}">Comments</a> &#8226;
    
{/if}
    {if allow_trackbacks}
    
({trackback_total}) <a href="{trackback_path="{my_template_group}/trackbacks"}">Trackbacks</a> &#8226;
    
{/if}
    
<a href="{title_permalink={my_template_group}/index}">Permalink</a>

    
<?php @include("{comment_path=page_elements/_comments}"); ?>
    <?php
@include("{comment_path=page_elements/_comment_form}"); ?>
{
/exp:weblog:entries}

Then i have the 2 mentioned includes. I will list just the page_elements/_comments template for now:

{exp:comment:entries weblog="{my_weblog_name}"}
    {comment}
    Posted by {url_or_email_as_author}  
&nbsp;on&nbsp; {comment_date format='%m/%d'} &nbsp;at&nbsp; {comment_date format='%h:%i %A'}
    
<hr/>
{/exp:comment:entries}

 Signature 

Mac Pro 4x3ghz, 1.8TB HD, 4G RAM, Dual 20” Screens in the house ... *drool*

Profile
 
 
Posted: 12 October 2007 01:03 PM   [ Ignore ]   [ # 9 ]  
Moderator
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  32911
Joined  05-14-2004

Is {my_weblog_name} assigned on the sub-template as well?  And is PHP set to input, or output?

 Signature 
Profile
MSG
 
 
Posted: 12 October 2007 01:12 PM   [ Ignore ]   [ # 10 ]  
Grad Student
Avatar
Rank
Total Posts:  72
Joined  06-06-2007

Hmm

{my_weblog_name} is not assigned in the comments template as well. Should it be? If so, how do I make it dynamic as well?

And PHP on blog/index is set to output

 Signature 

Mac Pro 4x3ghz, 1.8TB HD, 4G RAM, Dual 20” Screens in the house ... *drool*

Profile
 
 
Posted: 12 October 2007 01:21 PM   [ Ignore ]   [ # 11 ]  
Moderator
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  32911
Joined  05-14-2004

Yes, you need to use those first two lines in that template to assign it. If you’re going to be using that variable in many, many templates, then you might like to look at path.php global variables in the docs.

 Signature 
Profile
MSG
 
 
Posted: 12 October 2007 01:26 PM   [ Ignore ]   [ # 12 ]  
Grad Student
Avatar
Rank
Total Posts:  72
Joined  06-06-2007

hmm intersting, this works to display comments, i put it in my weblog:entries tag

{embed="page_elements/_comments" my_weblog_name="{my_weblog_name}" my_template_group="{my_template_group}" entry_id="{entry_id}"}

is there any reason the comment form would not work as well in this way? I suppose I will try.

How was this method doable and I didnt have to use PHP as mentioned before.

 Signature 

Mac Pro 4x3ghz, 1.8TB HD, 4G RAM, Dual 20” Screens in the house ... *drool*

Profile
 
 
Posted: 12 October 2007 02:18 PM   [ Ignore ]   [ # 13 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  319
Joined  06-14-2006

Lisa, I dimly recall that wiki entry. I’m not entirely clear what the difference between the PHP @include and an embed is, but the basic idea seems to be nesting the tags. If that’s more or less equivalent, why not pass the entry_id as an embed variable and use it for the comment:entries tag?

In the index template:

{exp:weblog:entries ...}
...
{embed="{my_template_group}/.comment_form" var_entry_id={entry_id}
{
/exp:weblog:entries}

In .comment_form:

{exp:comment:entries ... entry_id="{embed:var_entry_id}"}
...
{/exp:comment:entries}

If I weren’t busy prepping for a garage sale today, I’d try it out myself…

Profile
 
 
Posted: 12 October 2007 02:29 PM   [ Ignore ]   [ # 14 ]  
Moderator
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  32911
Joined  05-14-2004

The answer is simple:

The wiki entry was created before embeds could pass variables.

I never did use that method myself so I’m not sure where it might be hanging up at this point. =/

 Signature 
Profile
MSG
 
 
Posted: 12 October 2007 03:02 PM   [ Ignore ]   [ # 15 ]  
Grad Student
Avatar
Rank
Total Posts:  72
Joined  06-06-2007

hehe ... the downside of wiki documentation. How was I to know?

Thanks so much lisa, I think everything works just fine now. Right about now I am appreciating having paid or EE to get the kind of support you have provided smile

Thanks to you as well Markus!

 Signature 

Mac Pro 4x3ghz, 1.8TB HD, 4G RAM, Dual 20” Screens in the house ... *drool*

Profile
 
 
Posted: 12 October 2007 03:06 PM   [ Ignore ]   [ # 16 ]  
Moderator
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  32911
Joined  05-14-2004

Markus - thank you. =)

CodeOfficer; if you have found a working solution that takes advantage of EE’s current feature-set; then I would love to encourage you to update that wiki entry. I’d, of course, keep the warning there - or even add a second section using embeds rather than PHP.

I hope you will, anyway.  I’m glad you got it all working!

 Signature 
Profile
MSG
 
 
Posted: 12 October 2007 03:56 PM   [ Ignore ]   [ # 17 ]  
Grad Student
Avatar
Rank
Total Posts:  72
Joined  06-06-2007

Lisa, I added my more recent approach to the wiki, but the {embed} calls aren’t showing in the code examples, perhaps you can edit them to appear. I repeat, the {embed} code is there if you view it in edit, but wont display via the code blocks.

Thanks again.

http://expressionengine.com/wiki/Comments_on_Index/

 Signature 

Mac Pro 4x3ghz, 1.8TB HD, 4G RAM, Dual 20” Screens in the house ... *drool*

Profile
 
 
Posted: 12 October 2007 04:03 PM   [ Ignore ]   [ # 18 ]  
Moderator
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  32911
Joined  05-14-2004

Fixed that up, had to encode the { :

& #123;

no spaces. =)

 Signature 
Profile
MSG
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65027 Total Logged-in Users: 45
Total Topics: 82116 Total Anonymous Users: 22
Total Replies: 441313 Total Guests: 211
Total Posts: 523429    
Members ( View Memberlist )