Hoppa till huvudinnehåll

Keys

Keys are a way of extracting data from subpages. In a blog you have lots of posts and a main blog page. The main blog page extracts the title and image from each post using keys.

Uppdaterad för mer än en vecka sedan

Keys are a way of extracting data from subpages. In a blog you have lots of posts and a main blog page. The main blog page extracts the title and image from each post using keys.

Keys have broader applications beyond blogs, including products, articles, and other collections.

Template Structure

post.tpl Example

<div class="post">
<sf-image3 id="1" width="1170" height="400" key="image"></sf-image3>
<sf-singlerow id="2" key="title" html-element="h1"></sf-singlerow>
<sf-text id="3"></sf-text>
</div>

The template defines image and title keys for extraction.

blog.tpl Example

{ com_keys (
id:'1',
description: 'Blog posts',
class: 'posts',
html:'<a href="##{{ page.url }}" class="post">
<span class="image" style="background-image:url(##{{ keys.image | resize:120,120 }})"></span>
<span class="title">##{{ keys.title }}</span>
</a>',
sortBy:'publishedDate descending',
useChildPages: 'true',
limit: '9',
offset: '0'
) }

com_keys Reference Parameters

Parameter

Description

id

Namespace identifier

description

Displays when no subpages exist

class

CSS class for wrapper div

html

Repeating code per page

sortBy

Sort by date/name (ascending/descending)

limit

Maximum pages to display

perPage

Pages before pagination

paginationHtml

Custom pagination HTML

offset

Skip pages

exclude-self

Exclude current page

HTML Reference Variables

Variable

Description

##{{ page.url }}

Page URL

##{{ page.name }}

Page name

##{{ page.publishDate \

format:"%e %B, %Y"}}

Formatted publish date (uses PHP strftime formatting)

##{{ keys }}

Accesses subpage-defined keys

Fick du svar på din fråga?