Page 1 of 1

Help needed with ported theme, missing date

Posted: Sun Dec 11, 2005 5:57 pm
by carl_galloway
Hi all,

I'm working on porting the 'Connections' theme from WordPress over to Serendipity for a friend, and I'm having a couple of (hopefully) little issues.

First I need to know whether these are template problems or am I trying to fix something that is server/serendipity related.

The problem is that some of the entries on the startpage don't show their date, yet the timestamp is in the db and doesn't seem to be corrupt. Clicking to the detail page for these entries brings up the date as it should, so hopefully my stylesheet and entries.tpl are working correctly. Can anyone point me in the right direction?

Secondly, when I click on the polls archive my page seems to get mangled and I can't anything in my entries.tpl to tell me why. Do some plugin makes up their own stylesheets or am I missing something obvious. My apologies to the designer of the polls plugin if I've done something wrong.

EDIT: sorry guys, visit my site and use the template chooser to select 'Connections WP-port' to see what I'm talking about.

Cheers
Carl

Gee, I'm a dumkopf

Posted: Sun Dec 11, 2005 8:25 pm
by Guest
I just realised why my article dates aren't appearing on some of the entries on the front page - they were all posted on the same day!

Unfortunately my realisation doesn't help me. Argh, why does this have to be so difficult?

I've tried two different methods of getting the date,

{$entry.timestamp|@formatTime:DATE_FORMAT_ENTRY}

and

{$dategroup.date|@formatTime:DATE_FORMAT_ENTRY}

but neither of these seems to want to give me the date when an entry was posted on the same day as the one above it on the startpage. Does that make sense, hopefully the programmers reading this will understand.

So, now my question is this. I want the entry date to appear on every post on the startpage, and I don't want the date ignored if multiple posts were made that day. How do I do this?

My entries.tpl for that part looks like this;

Code: Select all

<!-- ENTRIES START -->
    {serendipity_hookPlugin hook="entries_header" addData="$entry_id"}

    {foreach from=$entries item="dategroup"}
    <div class="serendipity_Entry_Date">

        {if $dategroup.is_sticky}

        <p class="post-date">{$CONST.STICKY_POSTINGS}</p>
        {else}
        <p class="post-date">{$dategroup.date|@formatTime:DATE_FORMAT_ENTRY}</p>
        {/if}
        {foreach from=$dategroup.entries item="entry"}
      <div class="post-info">  
		<h2 class="post-title"><a href="{$entry.link}">{$entry.title}</a></h2>
            {$CONST.POSTED_BY} <a href="{$entry.link_author}">{$entry.author}</a> {$CONST.IN}
{foreach from=$entry.categories item="category" name="categories"}<a href="{$category.category_link}">{$category.category_name|@escape}</a>{if not $smarty.foreach.categories.last}, {/if}{/foreach}
                <br />
                {if $entry.has_comments}
                    {if $use_popups}
                     <a href="{$entry.link_popup_comments}" onclick="window.open(this.href, 'comments', 'width=480,height=480,scrollbars=yes'); return false;">{$entry.label_comments} ({$entry.comments})</a>
                    {else}
                        <a href="{$entry.link}#comments">{$entry.label_comments} ({$entry.comments})</a>
                    {/if}
                {/if}
                {if $entry.has_trackbacks}
                    {if $use_popups}
                        | <a href="{$entry.link_popup_trackbacks}" onclick="window.open(this.href, 'comments', 'width=480,height=480,scrollbars=yes'); return false;">{$entry.label_trackbacks} ({$entry.trackbacks})</a>
                    {else}
                        | <a href="{$entry.link}#trackbacks">{$entry.label_trackbacks} ({$entry.trackbacks})</a>
                    {/if}
                {/if}

                {if $entry.is_entry_owner and not $is_preview}
                        | <a href="{$entry.link_edit}">{$CONST.EDIT_ENTRY}</a>
                {/if}
</div>

            <div class="serendipity_entry_body">
                {$entry.body}
            </div>

Cheers
Carl

Posted: Sun Dec 11, 2005 8:31 pm
by carl_galloway
Above post was from me, sorry, keep forgetting when I clear my cache it also deletes the cookies.

Carl

Posted: Sun Dec 11, 2005 9:00 pm
by garvinhicking
The reason for this are those two foreach loops:

Code: Select all

{foreach from=$entries item="dategroup"} 
  {foreach from=$dategroup.entries item="entry"}
  {/foreach}
{/foreach}
This means that entries fmro the same day are looped within the first loop.
To get the behaviour you need, modify your template to this:

Code: Select all

<!-- ENTRIES START -->
    {serendipity_hookPlugin hook="entries_header" addData="$entry_id"}

    {foreach from=$entries item="dategroup"}
        {foreach from=$dategroup.entries item="entry"}
    <div class="serendipity_Entry_Date">

        {if $dategroup.is_sticky}

        <p class="post-date">{$CONST.STICKY_POSTINGS}</p>
        {else}
        <p class="post-date">{$dategroup.date|@formatTime:DATE_FORMAT_ENTRY}</p>
        {/if}
      <div class="post-info"> 
      <h2 class="post-title"><a href="{$entry.link}">{$entry.title}</a></h2>
            {$CONST.POSTED_BY} <a href="{$entry.link_author}">{$entry.author}</a> {$CONST.IN}
{foreach from=$entry.categories item="category" name="categories"}<a href="{$category.category_link}">{$category.category_name|@escape}</a>{if not $smarty.foreach.categories.last}, {/if}{/foreach}
                <br />
                {if $entry.has_comments}
                    {if $use_popups}
                     <a href="{$entry.link_popup_comments}" onclick="window.open(this.href, 'comments', 'width=480,height=480,scrollbars=yes'); return false;">{$entry.label_comments} ({$entry.comments})</a>
                    {else}
                        <a href="{$entry.link}#comments">{$entry.label_comments} ({$entry.comments})</a>
                    {/if}
                {/if}
                {if $entry.has_trackbacks}
                    {if $use_popups}
                        | <a href="{$entry.link_popup_trackbacks}" onclick="window.open(this.href, 'comments', 'width=480,height=480,scrollbars=yes'); return false;">{$entry.label_trackbacks} ({$entry.trackbacks})</a>
                    {else}
                        | <a href="{$entry.link}#trackbacks">{$entry.label_trackbacks} ({$entry.trackbacks})</a>
                    {/if}
                {/if}

                {if $entry.is_entry_owner and not $is_preview}
                        | <a href="{$entry.link_edit}">{$CONST.EDIT_ENTRY}</a>
                {/if}
</div>

            <div class="serendipity_entry_body">
                {$entry.body}
            </div>
Note how I shifted the content between the two foreach loops differently.

And yes, certain plugins have their own template files and use their own styles to format their content. The polls page might be one of them.

Regards,
Garvin

LEGEND!!!

Posted: Sun Dec 11, 2005 9:09 pm
by carl_galloway
Garvin, you are a legend!!

I'm not a programmer, and this stuff hurts my head, but I can definitely see the logic in your mod. You know it won't be long before Serendipity takes over the world. I think my friend will be very happy now that this theme is coming together. Few more css issues and then we're blasting off.

Thanks again,

Carl

Re: LEGEND!!!

Posted: Mon Dec 12, 2005 12:43 am
by garvinhicking
Cool stuff. And if you want to share your theme once it's finished... well, you know where to find me *gg*

Regards,
Garvin

Sharing?, no it's mine, all mine I tell you

Posted: Mon Dec 12, 2005 2:13 am
by carl_galloway
I'm actually really enjoying doing templates, might be a new career for me. Unfortunately I am very much an amateur, and don't want to get ahead of myself :)

Seriously, I will happily share this theme, and any other I do, however in this case the work isn't mine, and whilst the author is ok with others porting her work and making them available to download I also thought out of respect for her hard work that I wouldn't release this theme until I've finished it. I wouldn't want any mistake on my part to reflect badly on her because she is a professional designer. Should be able to make it available by the end of this week.

Carl

Re: Sharing?, no it's mine, all mine I tell you

Posted: Mon Dec 12, 2005 9:33 am
by garvinhicking
Sure, of course - that's all perfectly fine for us. We can wait, and don't feel pushed. Take the time you need, it's worth it. :-)

Best regards and have fun!
Garvin