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.
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.
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.
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.
@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.”
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.
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.
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?
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
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!
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.