I agree to the use of cookies in accordance with the Sourcefabric Privacy Policy.

Support our media development efforts

Please note: due to the quarantine measures required by the coronavirus outbreak, we are unable to answer the phone in our Prague office. Please send an email to contact@sourcefabric.org and someone will get back to you as soon as possible.

Who, what, when, where and why

Get the latest news about Sourcefabric software, solutions and ideas.

BACK TO BLOG OVERVIEW

Programming language for news: Newscoop's templates

When you're venturing into the territory of designing sites using Newscoop, $gimme serves as your map and compass. $gimme is your reliable friend, your eager spy and the keeper of all knowledge. $gimme will give you information and answer your questions.

"Give me the name of the article", "Give me the number of the issue", are requests $gimme will follow without even a shrug. Obviously, "give me" is how $gimme got its name. And $gimme speaks a simple language, along the lines of "gimme publication name" or "gimme user email." We like to refer to Newscoop's template language as a programming language for news.

$gimme and the Newscoop template language.

$gimme lets you list and arrange articles, display text and multimedia, prepare content for third-party services and include external content. It allows editors total design freedom and doesn't push them into a single way of presenting their stories.

The philosophy behind the Newscoop template language (and $gimme) has been to make it as intuitive and easy to use as possible. Here's how you would use $gimme to display the name (or headline) of an article, like "Newscoop 3 Cookbook now in shops":

{{ $gimme->article->name }}

Here's how you would use $gimme to display a section's description, such as "Film Reviews from the Venice Film Festival"

{{ $gimme->section->description }} 

Display the date when an issue was published:

{{ $gimme->issue->publish_date }}

Display the file name of an article attachment:

{{ $gimme->article->attachment->file_name }}

Display the caption of an image, like "Work started at Berlin's new airport":

{{ $gimme->image->caption }}

Display the map provider you're using for your site's base maps:

{{ $gimme->map->provider }}

Here are some more examples along the same lines:

{{ $gimme->article->keywords }}
{{ $gimme->article->comment->subject }}
{{ $gimme->publication->default_language }}
{{ $gimme->author->name }}
{{ $gimme->author->biography->text }}
{{ $gimme->image->photographer }}
{{ $gimme->user->name }}
{{ $gimme->user->phone }}

And there's more. In the Newscoop Cookbook you'll see $gimme in action, providing all kinds of information added by editors and journalists.

Separation of Presentation and Content

Web designers use the concept of "separation of presentation and content" every day when developing in HTML and CSS. In the HTML you can emphasize parts of the content with the em element, so whatever is wrapped inside em tags is "what" needs to be emphasized. "How" the emphasis is being displayed can be set in the CSS file, assigning font family, size, style, color and so on.

Develop your design without touching any code

The Newscoop template engine gives you maximum flexibility to develop templates in HTML, CSS and JavaScript any way you like. You don't need to think in terms of blocks or widgets, and you can use sample text like "Lorem ipsum" when fine-tuning your layout. Turning your design into a template for Newscoop means to replace the sample text with $gimme.

Watch $gimme at work

On its own, $gimme can pull information out of the content database and place it inside your template. When you set it loose inside Newscoop templates, it advances to become the project leader of your publication; beyond simple retrievals and replacements, $gimme is then in charge of making design decisions. Checking information with $gimme can create the most complex designs in very few lines of code.

To put $gimme into action, you'll use functions from the Newscoop template language. These functions are developed with the news organisation in mind, delivering publication content with simple commands. The functions available are being expanded continuously alongside new features in Newscoop, and an expanding range of features for already existing functionality.

The Newscoop template language is an extension to a popular and powerful template engine called Smarty, which itself is written in PHP. Smarty is popular among PHP users and developers, and comes with a rich set of functionality you can use in your templates. You will see some examples in this cookbook and find a full reference online at http://www.smarty.net

With every new Newscoop version the template language and $gimme become more powerful. We keep developing and integrating new features, and extending the current ones, but we do also care about backward compatibility, which means we are not going to break your current website.

Want to find out more?

This developer's guide was taken from the Newscoop 3 Cookbook - Developer's Guide - a free resource available online, in print, as pdf and as epub via the Sourcefabric website. Thanks to all the original authors.

The Newscoop 3 Cookbook is a work in progress and open to your input. Dedicated to Open Source software development, Sourcefabric believes that the software and its documentation are open to the community. The more contributors add to the products, the more errors get caught and fixed, the more features are implemented. We also believe that software improves from good documentation, and documentation improves with the wide use of software.

BACK TO TOP