Page 1 of 1

Entry modification per category & date format

Posted: Sat Jul 27, 2013 1:20 pm
by avfunk
At this moment I'm modifying a template to suit my needs. I was wondering about several things.

1. Is it possible to create separate entries.tpl files for separate categories so that I can adjust the posting behavior a little bit for different categories? If not, is it possible to specify it per category in the single entries.tpl file somehow/somewhere?

2. Is it possible to display only the entry body on the main page, but the full article, entry & extended body, on a category page? I couldn't find any config options for this anywhere.

3. How do I change the date format? I've tried several things, but they don't seem to stick. I've made a change in the lang/serendipity_lang_en.inc.php and the date format constant looks like this:

Code: Select all

@define('DATE_FORMAT_ENTRY', '%A %d-%m-%Y');
This Should display the date as "Saturday 27-07-2013" if I'm not mistaken but it still displays the date as "Saturday, July 27. 2013"

I've added the same line to the lang_en.inc.php file in the template dir just to make sure I covered everything. Language of my blog is set to english, so it should be working. Am i missing something here?

Thanks in advance for your answers :D

Re: Entry modification per category & date format

Posted: Sat Jul 27, 2013 1:51 pm
by yellowled
avfunk wrote:1. Is it possible to create separate entries.tpl files for separate categories so that I can adjust the posting behavior a little bit for different categories? If not, is it possible to specify it per category in the single entries.tpl file somehow/somewhere?
I guess the easiest way to achieve this would be to use $category and/or $category_info, e.g. checking a given category's id in an if statement.

Code: Select all

{if $category == '1'}
{* do stuff *}
{else}
{* do different stuff *}
{/if}
avfunk wrote:2. Is it possible to display only the entry body on the main page, but the full article, entry & extended body, on a category page? I couldn't find any config options for this anywhere.
That's something you'd need to adapt in your tpl files using $view in entries.tpl, e.g.

Code: Select all

{if $view == "categories"}
  {$entry.body}
  {if $entry.is_extended}
      <div id="extended">
      {$entry.extended}
      </div>
  {/if}
{else}
  {$entry.body}
{/if}
or something like that. However, this might need some testing, I'm not sure if this really is what you want to do.
avfunk wrote:3. How do I change the date format?
Probably the easiest way is to use a Smarty modifier in your tpl files like 2k11 does.

Code: Select all

{$entry.timestamp|@formatTime:$template_option.date_format}
$template_option.date_format is a variable set by 2k11's theme options, basically a placeholder for PHP's strftime format. So if you can use it like this as well

Code: Select all

{$entry.timestamp|@formatTime:'%A %d-%m-%Y'}
(also works on other timestamps, e.g. comments)

YL

Re: Entry modification per category & date format

Posted: Sat Jul 27, 2013 1:55 pm
by yellowled
Also note that there's always the event plugin Properties/Templates of categories:
This plugin provides additional properties for categories and their entries, including custom templates, sort order, display limit, password protection, and RSS hiding.
Of course, you can use this to assign slightly modified copies of the same “base” template to categories. Personally, I have always found this plugin to have its quirks, but it is an option.

YL

Re: Entry modification per category & date format

Posted: Sat Jul 27, 2013 2:17 pm
by Timbalu
For the first question there is also the option (though YL's solution is more simple) to use the categorytemplates plugin slightly modified, if you make different named copies of your own template supporting different entries.tpl files.

Ups, soory didn't read the previous post... :oops: