
The Campsite extension to Smarty will initialize objects that are specific to Campsite: article, section, issue, image etc. These objects are instantiated from meta classes (e.g. MetaArticle, MetaSection etc.) and use method call overloading for allowing the web designer to access object properties (see: http://www.php.net/manual/en/language.oop5.overloading.php). This way we won't expose the core Article, Section etc. objects to the web designer so he/she won't be able to play with the database. These meta classes will only implement the _ _get() method, _ _set() will be empty or throw an error. Meta classes will use the existing classes (Publication, Issue, Section etc.) to retrieve the data. Meta classes will also implement the method "defined()" that returns true if the object instantiated from the class was actually initialized.
The template engine will initialize the $campsite object, which stores the whole Campsite environment (meaning all template parameters, objects, properties etc.). The $campsite object has the following read/write properties:
and the following read-only properties:
Old syntax:
1. <!** #statement# #attribute# #value#>⁞ 2. <!** #statement# default> 3. <!** #statement# current> 4. <!** #statement# off>
New syntax:
1. {{ set_#statement# #attribute#="#value#" }}
2. {{ set_default_#statement# }}
3. {{ set_current_#statement# }}
4. {{ unset_#statement# }}
Old syntax:
<!** Local> <!** EndLocal>
New syntax:
{{ local }}
{{ /local }}
We will use the include statement implemented in Smarty.
Old syntax:
1. <!** HTMLEncoding on> 2. <!** HTMLEncoding off>
New syntax:
1. {{ enable_html_encoding }}
2. {{ disable_html_encoding }}
<!** Article number 125>
changes to:
{{ set_article number="125" }}
<!** Article off>
changes to:
{{ unset_article }}
Old syntax:
<!** List [length #value#] [columns #value#] #statement# [#contraints#]
[order #order_constraints#]>
<!** ForEmptyList>
<!** EndList>
New syntax:
{{ list_#statement#s [name="#value#"] [length="#value#"] [columns="#value#"]
[constraints="#constraints#"] [order="#order_constraints#"] }}
{{ if $currentList->empty }}
{{ /if }}
{{ /list_#statement#s }}
Constraints will require a 'Constraint Parser'. The Constraint Parser has the following requirements:
* constraints can contain variables * constraints can contain "&&"(AND) and "||" (OR) * constraints can contain parenthesis
Old syntax:
1. <!** List [length #value#] [columns #value#] ArticleAttachment ForCurrentLanguage> 2. <!** List [length #value#] [columns #value#] ArticleAttachment ForAllLanguages> 3. <!** List [length #value#] [columns #value#] Subtitle>
New syntax:
1. {{ list_article_attachments [name="#name#"] [length="#value#"]
[columns="#value#"] language="current" }}
2. {{ list_article_attachments [name="#name#"] [length="#value#"]
[columns="#value#"] language="all" }}
3. {{ list_subtitles [name="#name#"] [length="#value#"] [columns="#value#"]
[articleType="#value#"] field="#value#" }}
In the exception example 3 articleType and field attributes are read from "With" statement from the old template language.
Old syntax:
1. <!** If [not] #statement# > 2. <!** If [not] #statement# #attribute# > 3. <!** If [not] #statement# #attribute# #value# > 4. <!** If [not] #statement# #attribute# #value# [#value#]+ > 5. <!** If [not] #statement# #attribute# #operator# #value# > 6. <!** If [not] #statement# #article_type# #attribute# #operator# #value# >
New syntax:
1. {{ if [!] $#statement# }}
2. {{ if [!] $#statement#->#attribute# }}
3. {{ if [!] ($#statement#->#attribute# == "#value#") }}
4. {{ if [!] ($#statement#->#attribute# == "#value#"
[and $#statement#->#attribute# == "#value#"]+ ) }}
5. {{ if [!] ($#statement#->#attribute# #smarty_corresponding_operator# "#value#") }}
6. {{ if [!] ($#statement#->type->#article_type#->#attribute#
#smarty_corresponding_operator# "#value#") }}
Old syntax:
1. <!** If [not] Allowed> 2. <!** If [not] Article upload_date #operator# #value# > 3. <!** If [not] Article has_keyword #value# > 4. <!** If [not] Article translated_to #value# > 5. <!** If [not] CurrentSubtitle > 6. <!** If [not] Image #value# > 7. <!** If [not] Login #attribute# > 8. <!** If [not] NextItems > 9. <!** If [not] PreviousItems > 10. <!** If [not] NextSubtitles > 11. <!** If [not] PrevSubtitles > 12. <!** If [not] Search #attribute# > 13. <!** If [not] User #attribute# > 14. <!** If [not] Subtitle number #operator# #value# >
New syntax:
1. {{ if [!] $article->content_accessible }}
2. {{ if [!] $article->creation_date #smarty_corresponding_operator# "#value#" }}
3. {{ if [!] $article->keyword == "#value#" }}
4. {{ if [!] $article->translationLang == "#value#" }}
5. {{ if [!] $article->subtitle->is_current }}
6. {{ if [!] $article->image_number == "#value#" }}
7. {{ if [!] $user->login_#attribute# }}
8. {{ if [!] $current_list->length gt $current_list->last_element->index }}
9. {{ if [!] $current_list->first_element->index gt 1 }}
10. {{ if [!] $current_list->length gt $current_list->last_element->index }}
11. {{ if [!] $current_list->first_element->index gt 1 }}
12. {{ if [!] $article->search#attribute# }}
13. {{ if [!] $user->subscription_#attribute# }}
14. {{ if [!] $article->subtitle->number #smarty_corresponding_operator# "#value#" }}
This statement is not used anymore, see example 3 from "List" exceptions.
Old syntax:
<!** #statement# [#option#]+ >
New syntax:
{{ #statement# [options="[#option#]+"] }}
Where #statement# can be one of the following: URIPath, URLParameters, URI, URL, FormParameters?.
Old syntax:
1. <!** Date #attribute# > 2. <!** Date #date_format# >
New syntax:
1. {{ $smarty.now|camp_date_format:"#corresponding_smarty_date_part#" }}
2. {{ $smarty.now|camp_date_format:"#date_format#" }}
Old syntax:
1. <!** Print #statement# #attribute# > 2. <!** Print Article [#article_type#] #attribute# > 3. <!** Print #statement# #attribute# #date_format# >
New syntax:
1. {{ $#statement#->#attribute# }}
2. {{ $article->[type->#article_type#->]#attribute# }}
3. {{ $#statement#->#attribute#|camp_date_format:"#date_format#" }}
1. <!** Print ArticleAttachment #attribute# > 2. <!** Print ArticleComment #attribute# > 3. <!** Print ArticleComment readerEmailObfuscated > 4. <!** Print ArticleComment readerEmailPreviewObfuscated > 5. <!** Print Subtitle name > 6. <!** Print Image [#imageNumber#] #attribute# [#date_format#] > 7. <!** Print List #attribute# > 8. <!** Print Login error > 9. <!** Print Search #attribute# > 10. <!** Print Subscription #attribute# [#date_format#] >
1. {{ $article->attachment->#attribute# }}
2. {{ $article->comment->#attribute# }}
3. {{ $article->comment->reader_email|camp_obfuscate }}
4. {{ $article->comment->reader_email_preview|camp_obfuscate }}
5. {{ $article->subtitle->name }}
6. {{ $article->image[\[#imageNumber#\]]->#attribute#[|camp_date_format:"#date_format#"] }}
7. {{ $current_list->#attribute# }}
8. {{ $user->login->error_message }}
9. {{ $article->search->#attribute# }}
10. {{ $user->subscription->#attribute#[|camp_date_format:"#date_format#"] }}
{{ $article->title }}
{{ $article->type->data->intro }}
Old syntax:
1. <!** #statement# #template_name# #submit_button_name# >
2. <!** ArticleCommentForm #template_name# #submit_button_name# [#preview_button_name#] >
3. <!** Subscription #subscription_type# #template_name# #submit_button_name#
[#total_field_name# #evaluate_button_name#] >
New syntax:
1. {{ #statement#_form template="#template_name#" submit_button="#submit_button_name#" }}
2. {{ article_comment_form template="#template_name#" submit_button="#submit_button_name#"
[preview_button="#preview_button_name#"] }}
3. {{ subscription_form type="#subscription_type#" template="#template_name#"
submit_button="#submit_button_name#"
[total_field="#total_field_name#"]
[evaluate_field="#evaluate_button_name#"] }}
The statements that match rule 1 are: Login, Search and User.
Old syntax:
1. <!** Edit #statement# #attribute# > 2. <!** Edit #statement# #attribute# #integer_value# > 3. <!** Edit #statement# #attribute# HTML #html_code# >
New syntax:
1. {{ camp_edit object="#statement#" attribute="#attribute#" }}
2. {{ camp_edit object="#statement#" attribute="#attribute#" }}
3. {{ camp_edit object="#statement#" attribute="#attribute#" html_code="#html_code#" }}
Old syntax:
1. <!** Select #statement# #attribute# > 2. <!** Select User gender #male_name_string# #female_name_string# >
New syntax:
1. {{ camp_select object="#statement#" attribute="#attribute#" }}
2. {{ camp_select object="user" attribute="gender" male_name="#male_name_string#"
female_name="#female_name_string#" }}