12/11/2011 3:50pm

PHP | Problem - Collection of code


<% if Menu(2) %>

<ul id="Menu2">
<% control Menu(2) %>
<li class="$LinkingMode"><a href="$Link" title="Go to the &quot;{$Title}&quot; page">$MenuTitle</a></li>
<% end_control %>
</ul>
<% end_if %>


Basic Logoc:
and :
<%if foo && bar %>
or :
<%if foo || bar %>
<% if foo %>
<% else_if bar %>
<% else %>

http://api.silverstripe.org/2.4/sapphire/model/Text.html
$Content.FirstParagraph
$Content.LimitWordCount(25)
$Content.FirstSentence.
$Content.LimitCharacters ( [$limit = 20], [$add = "..."] )
.........................................................................
_ controller extend Page_controller << controller is ONLY processes when that page type is visited. when DataObject is ready in the DB for access from anywhere.
.........................................................................
They are 2 different types of template. ArticleHolder.ss maps to a class ArticleHolder but the search template maps to a function on Page - function action() on a ArticleHolder().

So if you have a function date() on your ArticleHolder class, and a url like site.com/articles/date then it'll use ArticleHolder_date.ss.

See the template documentation for more information.



<% base_tage %>
$content
$SilverStripeNavigator
$Title
$MetaTags
$MenuTitle
$link
$LinkingMode
$Breadcrumbs
<% if Level(2) %>
<% end_if %>

<% if Menu(2) %>
<% control Menu(2) %>
<% end_control %>
<% end_if %>


CSS Files
By standard SilverStripe uses 3 CSS Files for your site -
• layout.css contains the layout and design of the site
• typography.css contains the styling for the text/fonts/links (used in both front and back ends)
• form.css styling for forms. Overriding
The templating system will search for the appropriate files in the following order:
1. mysite (or other name given to site folder)
2. themes
3. module (eg blog)
Subthemes
If you have a theme called mytheme_forum, it is considered to be a 'subtheme' of the mytheme theme. This lets module developers release extensions to popular themes that will let their module work with that theme.
A subtheme overrides the files in the module. So for instance, if you have the forum setup instead of editing the files within the forum/ module you would create a themes/yourtheme_forum/ folder.

ThemeDir
$ThemeDir
$ThemeDir(forum)

If you want to refer to an image or other file asset in a .ss template, use $ThemeDir. For example:
<img src="$ThemeDir/images/log.gif" />



If your image is in a subtheme, you can refer to that with an argument to ThemeDir. For example, if your image was in mytheme_forum, you could use the following code:
<img src="$ThemeDir(forum)/images/log.gif" />


Including Javascript & CSS
http://doc.silverstripe.org/sapphire/en/reference/requirements
Including inside PHP Code
Requirements::javascript("cms/javascript/LeftAndMain.js");
Requirements::css("cms/css/TreeSelector.css");

Including inside Template files
<% require css(cms/css/TreeSelector.css) %>
<% require themedCSS(TreeSelector) %>
<% require javascript(cms/javascript/LeftAndMain.js) %>
Note that currently (as of 2.3) you cannot pass a second parameter to a function via the template parser so doing the following will not work.
<% require css(cms/css/TreeSelector.css, 'screen,projection') %>
Combining Files
You can concatenate several CSS or javascript files into a single dynamically generated file. This increases performance reducing HTTP requests. Note that for debugging purposes combined files is disabled in devmode.
1
2
3
4
5
6
7
8 // supports CSS + JS
Requirements::combine_files(
'foobar.js',
array(
'mysite/javascript/foo.js',
'mysite/javascript/bar.js',
)
);
By default it stores the generated file in the assets/ folder but you can configure this by setting
1
2 // relative from the base folder
Requirements::set_combined_files_folder('folder');
If SilverStripe doesn't have permissions on your server to write these files it will default back to including them individually .

http://doc.silverstripe.org/sapphire/en/
http://doc.silverstripe.org/sapphire/en/reference/built-in-page-controls

Quick Reference
Below is a list of fields and methods that are typically available for templates (grouped by their source) - use this as a quick reference (not all of them are described above):
All methods available in Page_Controller
$NexPageLink, $Link, $RelativeLink, $ChildrenOf, $Page, $Level, $Menu, $Section2, $LoginForm, $SilverStripeNavigator, $PageComments, $Now, $LinkTo, $AbsoluteLink, $CurrentMember, $PastVisitor, $PastMember, $XML_val, $RAW_val, $SQL_val, $JS_val, $ATT_val, $First, $Last, $FirstLast, $MiddleString, $Middle, $Even, $Odd, $EvenOdd, $Pos, $TotalItems, $BaseHref, $Debug, $CurrentPage, $Top
All fields available in Page_Controller
$ID, $ClassName, $Created, $LastEdited, $URLSegment, $Title, $MenuTitle, $Content, $MetaTitle, $MetaDescription, $MetaKeywords, $ShowInMenus, $ShowInSearch, $HomepageForDomain, $ProvideComments, $Sort, $LegacyURL, $HasBrokenFile, $HasBrokenLink, $Status, $ReportClass, $ParentID, $Version, $EmailTo, $EmailOnSubmit, $SubmitButtonText, $OnCompleteMessage, $Subscribe, $AllNewsletters, $Subject, $ErrorCode, $LinkedPageID, $RedirectionType, $ExternalURL, $LinkToID, $VersionID, $CopyContentFromID, $RecordClassName
All methods available in Page
$Link, $LinkOrCurrent, $LinkOrSection, $LinkingMode, $ElementName, $InSection, $Comments, $Breadcrumbs, $NestedTitle, $MetaTags, $ContentSource, $MultipleParents, $TreeTitle, $CMSTreeClasses, $Now, $LinkTo, $AbsoluteLink, $CurrentMember, $PastVisitor, $PastMember, $XML_val, $RAW_val, $SQL_val, $JS_val, $ATT_val, $First, $Last, $FirstLast, $MiddleString, $Middle, $Even, $Odd, $EvenOdd, $Pos, $TotalItems, $BaseHref, $CurrentPage, $Top
All fields available in Page
$ID, $ClassName, $Created, $LastEdited, $URLSegment, $Title, $MenuTitle, $Content, $MetaTitle, $MetaDescription, $MetaKeywords, $ShowInMenus, $ShowInSearch, $HomepageForDomain, $ProvideComments, $Sort, $LegacyURL, $HasBrokenFile, $HasBrokenLink, $Status, $ReportClass, $ParentID, $Version, $EmailTo, $EmailOnSubmit, $SubmitButtonText, $OnCompleteMessage, $Subscribe, $AllNewsletters, $Subject, $ErrorCode, $LinkedPageID, $RedirectionType, $ExternalURL, $LinkToID, $VersionID, $CopyContentFromID, $RecordClassName



Image
Introduction
Represents an image object, inheriting all base functionality from the file class with extra functionality including resizing.
Resizing Images in PHP
The following are methods defined on the GD class which you can call on Image Objects. Note to get the following to work you need to have GD2 support in your PHP installation and // manipulation functions
$image->resize(width,height); // Basic resize, just skews the image
$image->resizeRatio(width,height) // Resizes an image with max width and height
$image->paddedResize(width,height) // Adds padding after resizing to width or height.
$image->croppedResize(width,height) // Crops the image from the centre, to given values.
$image->resizeByHeight(height) // Maximum height the image resizes to, keeps proportion
$image->resizeByWidth(width) // Maximum width the image resizes to, keeps proportion
$image->greyscale(r,g,b) // alters image channels ===
// values
$image->getHeight() // Returns the height of the image.
$image->getWidth() // Returns the width of the image
$image->getOrientation() // Returns a class constant: ORIENTATION_SQUARE or ORIENTATION_PORTRAIT or ORIENTATION_LANDSCAPE



Resizing in Templates
You can call certain resize functions directly from the template, to use the inbuilt GD functions as the template parser supports these, for example SetWidth() or SetHeight().
For output of an image tag with the image automatically resized to 80px width, you can use:
$Image.SetWidth(80) // returns a image 80px wide, ratio kept the same
$Image.SetHeight(80) // returns a image 80px tall, ration kept the same
$Image.SetSize(80,80) // returns a 80x80px padded image
$Image.SetRatioSize(80,80) // **New in 2.4** returns an image scaled proportional, with its greatest diameter scaled to 80px
$Image.PaddedImage(80, 80) // Returns an 80x80 image. Unused space is padded white. No crop. No stretching
$Image.Width // returns width of image
$Image.Height // returns height of image
$Image.Orientation // returns Orientation
$Image.Filename // returns filename
$Image.URL // returns filename
$Height
$Width
$CroppedImage(600,400) (with DOM)
$CroppedImage(600,400).URL // URL !!!

Data Types
These are the data-types that you can use when defining your data objects. They are all subclasses of DBField for introducing their usage.
Types
• Varchar: A variable-length string of up to 255 characters, designed to store raw text
• Text: A variable-length string of up to 2 megabytes, designed to store raw text
• HTMLVarchar: A variable-length string of up to 255 characters, designed to store HTML
• HTMLText: A variable-length string of up to 2 megabytes, designed to store HTML
• Enum: An enumeration of a set of strings
• Boolean: A boolean field.
• Int: An integer field.
• Decimal: A decimal number.
• Currency: A number with 2 decimal points of precision, designed to store currency values.
• Percentage: A decimal number between 0 and 1 that represents a percentage.
• Date: A date field
• SS_Datetime: A date / time field
• Time: A time field

Form Field Types ¶
• SimpleHTMLEditorField // DOM Related + Give basic Editor UI
• AjaxUniqueTextField: Text field that automatically checks that the value entered is unique for the given set of fields in a given set of tables
• AutocompleteTextField
• ConfirmedPasswordField: Shows two password-fields, and checks for matching passwords.
• CreditCardField
• CurrencyField
• EmailField
• HTMLEditorField: A WYSIWYG editor field, powered by tinymce.
• NumericField: A Single Numeric field extending a typical TextField but with validation.
• PasswordField
• UniqueRestrictedTextField: Text field that automatically checks that the value entered is unique for the given set of fields in a given set of tables
• UniqueTextField: Text field that automatically checks that the value entered is unique for the given set of fields in a given set of tables
Date/Time
• DateField: Represents a date in a textfield (New Zealand)
• DatetimeField: Combined date- and time field
• TimeField: Represents time in a textfield (New Zealand)

Structure
• CompositeField: Base class for all fields that contain other fields. Uses <div> in template, but doesn't necessarily have any visible styling.
• FieldGroup: Same as CompositeField, but has default styling (indentation) attached in CMS-context.
• FieldSet: Basic container for sequential fields, or nested fields through CompositeField. Does NOT render a <fieldgroup>.
• TabSet
• Tab
Actions
• Form for more info
• InlineFormAction: Render a button that will act as If you want to add custom behaviour, please set {inlcudeDefaultJS} to false and work with behaviour.js.
• Image: Action that uses an image instead of a button
• InlineFormAction: Prevents placement of a button in the CMS-button-bar.
Files
• FileField: Simple file upload dialog.
• FileIFrameField: File uploads through an iframe
• ImageField: Image upload through an iframe, with thumbnails and file-selection from existing assets
• SimpleImageField: SimpleImageField provides an easy way of uploading images to Image has_one relationships. Unlike ImageField, it doesn't use an iframe.


new TextareaField(
$name = "description",
$title = "Description",
$rows = 8,
$cols = 3,
$value = "This is the default description"
);

Relations
• ComplexTableField: Provides a tabuar list in your form with view/edit/add/delete links to modify records with a "has-one"-relationship (in a lightbox-popup).
• HasManyComplexTableField
• HasOneComplexTableField
• LanguageDropdownField: An extension to dropdown field, pre-configured to list languages. Tied into i18n.
• ManyManyComplexTableField
• TableField
• TableListField
• TreeDropdownField
• TreeMultiselectField: represents many-many joins using a tree selector shown in a dropdown-like element
• WidgetArea
Dataless/Utility
• DatalessField - Base class for fields which add some HTML to the form but don't submit any data or save it to the database
• HeaderField: Renders a simple <h1>-<h6> header
• HiddenField
• LabelField
• LiteralField: Renders arbitrary HTML into a form.
CMS Field Editor
Please see HTMLEditorField for in-depth documentation about custom forms created through a GUI in the CMS.

if(strpos($_SERVER['REQUEST_URI'], '/blog') === 0) SSViewer::set_theme('blog');

PHP <<<<<<<<<<<<<<<<<<<<<<<<<<<<PHP
Members & Administration

function init(){ parent::init(); if(member_logged_in){setThemeHere;}}

Set a page type settings from PHP , Set Default config !
static $defaults = array(
"ShowInMenus" => 0,
"ShowInSearch" => 0
);


48 Comments 48 Solutions

05/01/2015 3:10pm

PHP | Solution - XmELZuNpNS

<a href=https://www.facebook.com/buyxanax>buy xanax</a> xanax effects on pregnancy - generic xanax gg 258


05/01/2015 12:48pm

PHP | Solution - SRwvSKnxdw

<a href=https://www.facebook.com/buyxanax>buy xanax</a> xanax online uk - xanax and alcohol fatal


05/01/2015 3:21am

PHP | Solution - wYLbcsqJdA

<a href=https://www.facebook.com/buyxanax>where can i buy xanax online legally</a> xanax side effects confusion - what is a generic xanax


05/01/2015 12:32am

PHP | Solution - rQIllfbKgk

<a href=https://www.facebook.com/buyxanax>buy xanax</a> xanax side effects dogs - buy alprazolam 0.5mg online


04/01/2015 10:09pm

PHP | Solution - naxbJZrgVf

<a href=https://www.facebook.com/buyambien>buy ambien</a> ambien cr 12.5 mg espanol - ambien cr generic us


04/01/2015 5:48pm

PHP | Solution - nGGRyQrTrI

<a href=https://www.facebook.com/buyxanax>buy xanax</a> usual dosage xanax anxiety - xanax side effects memory


04/01/2015 1:09pm

PHP | Solution - AdkvNnUzCl

<a href=https://www.facebook.com/buyxanax>xanax price</a> xanax xr online - xanax drug test detection time urine


04/01/2015 12:15pm

PHP | Solution - gZWtKkWuAS

<a href=https://www.facebook.com/buyambien>online ambien</a> drug interactions ambien nyquil - ambien online with prescription


04/01/2015 12:06pm

PHP | Solution - PzmRbMSfTj

<a href=https://www.facebook.com/buyambien>ambien no prescription</a> buy ambien online overnight delivery - ambien side effects forum


04/01/2015 6:50am

PHP | Solution - ryMjexASMM

<a href=https://www.facebook.com/buyxanax>buy xanax</a> xanax xr 2mg vs xanax 2mg - xanax side effects drugs


04/01/2015 12:23am

PHP | Solution - QhQTiucfpx

<a href=https://www.facebook.com/buyambien>ambien no prescription</a> much generic ambien walmart - ambien high long


03/01/2015 10:27pm

PHP | Solution - utdedAUNzO

<a href=https://www.facebook.com/buyxanax>purchase xanax</a> xanax dosage recommended - buy xanax canada pharmacy


03/01/2015 7:14pm

PHP | Solution - jRttirsRJu

<a href=https://www.facebook.com/buyxanax>xanax 1mg</a> .5mg xanax for anxiety - xanax side effects dry eyes


03/01/2015 5:21pm

PHP | Solution - YTEmvXilSd

<a href=https://www.facebook.com/buyambien>ambien no prescription</a> ambien cr recreational use - dark ambien music online


03/01/2015 1:26pm

PHP | Solution - VNihkOzSYZ

<a href=https://www.facebook.com/buyambien>buy zolpidem</a> ambien side effects hiccups - makes generic ambien


03/01/2015 10:28am

PHP | Solution - RrcWnsqfzf

<a href=https://www.facebook.com/buyxanax>can you buy xanax online legally</a> order valium xanax online - xanax zantac


03/01/2015 9:20am

PHP | Solution - jGwSbSrcCc

<a href=https://www.facebook.com/buyxanax>no prescription xanax</a> xanax online consultation - xanax side effects mayo clinic


03/01/2015 4:46am

PHP | Solution - wxVbrZQQGx

<a href=https://www.facebook.com/buyambien>buy ambien</a> ambien pill id - buy ambien online usa


03/01/2015 2:39am

PHP | Solution - VcxhPEPWuN

<a href=https://www.facebook.com/buyambien>buy ambien online</a> ambien cr eating - legal to buy ambien online


02/01/2015 11:22pm

PHP | Solution - cFjRBXWDlO

<a href=https://www.facebook.com/buyxanax>xanax generic</a> buy xanax online no prescription needed - xanax withdrawal and itching


02/01/2015 11:03pm

PHP | Solution - djLFnQQphb

<a href=https://www.facebook.com/buyxanax>online xanax no prescription</a> 8 mg xanax side effects - xanax dosage in children


02/01/2015 5:24pm

PHP | Solution - IDLTcVplOd

<a href=https://www.facebook.com/buyambien>buy ambien</a> ambien cr 12.5 overdose - ambien overdose brain damage


02/01/2015 3:52pm

PHP | Solution - vjiEoqBOSE

<a href=https://www.facebook.com/buyambien>buy ambien</a> ambien pill code - can i order ambien online


02/01/2015 1:37pm

PHP | Solution - AJNQMUeGtr

<a href=https://www.facebook.com/buyxanax>buy xanax</a> buy xanax online with no prescription needed - xanax generic identify


02/01/2015 12:01pm

PHP | Solution - SrCQRIICaF

<a href=https://www.facebook.com/buyxanax>buy xanax</a> xanax pills side effects - order xanax fast shipping


02/01/2015 7:31am

PHP | Solution - WdghzzFmrY

<a href=https://www.facebook.com/buyambien>ambien online</a> price of ambien cr at walgreens - ambien overdose bluelight


02/01/2015 2:58am

PHP | Solution - bUSNJcQchm

<a href=https://www.facebook.com/buyxanax>buy xanax</a> buy xanax online consultation - xanax bars white mg


02/01/2015 12:22am

PHP | Solution - yFzMTtegyu

<a href=https://www.facebook.com/buyxanax>xanax alprazolam</a> xanax xr dosage duration - xanax withdrawal how long


01/01/2015 11:50pm

PHP | Solution - BVfiXwyBpJ

<a href=https://www.facebook.com/buyambien>ambien sale</a> sleepwalking while on ambien - ambien cr breaking in half


01/01/2015 9:35pm

PHP | Solution - okrRYtzdXT

<a href=https://www.facebook.com/buyambien>buy ambien</a> zolpidem ambien urine urinalysis - zolpidem tartrate or ambien


01/01/2015 5:47pm

PHP | Solution - ZdfvjkZwPh

<a href=https://www.facebook.com/buyxanax>xanax 2mg</a> xanax drug effects - causes xanax withdrawal xanax withdrawal


01/01/2015 1:19pm

PHP | Solution - EzykiAYgdC

<a href=https://www.facebook.com/buyxanax>buy xanax no prescription</a> generic equivalent for xanax - order xanax no prescription


01/01/2015 11:45am

PHP | Solution - QjlAyeAaKZ

<a href=https://www.facebook.com/buyambien>ambien no prescription</a> generic ambien name - what ambien pill looks like


01/01/2015 7:28am

PHP | Solution - vgXoLvEZIx

<a href=https://www.facebook.com/buyambien>buy ambien</a> ambien 10mg - does ambien sleeping pill look like


01/01/2015 1:39am

PHP | Solution - rKSILNgffH

<a href=https://www.facebook.com/buyxanax>buy xanax</a> buy xanax alprazolam online - buy xanax from india


01/01/2015 12:37am

PHP | Solution - OpqbSKVpCj

<a href=https://www.facebook.com/buyambien>buy ambien</a> 10mg ambien too much - cheap ambien no prescription


31/12/2014 6:24pm

PHP | Solution - GOprBuwnFc

<a href=https://www.facebook.com/buyambien>ambien no prescription</a> ambien dose - ambien sleeping pill over counter


31/12/2014 3:02pm

PHP | Solution - pbbUrnQksz

<a href=https://www.facebook.com/buyxanax>buy xanax</a> generic for xanax alprazolam - dosage of xanax for anxiety


31/12/2014 2:02pm

PHP | Solution - ATDQSaorLO

<a href=https://www.facebook.com/buyambien>buy ambien</a> ambien side effects tinnitus - ambien no prescription overnight delivery


31/12/2014 5:18am

PHP | Solution - DWfenbWweD

<a href=https://www.facebook.com/buyambien>can you buy ambien online</a> discount ambien - ambien dosage 10


31/12/2014 2:58am

PHP | Solution - LFecXMJsix

<a href=https://www.facebook.com/buyxanax>buy xanax</a> 4 bars xanax - xanax kratom


31/12/2014 2:06am

PHP | Solution - CbtEkVJTqu

<a href=https://www.facebook.com/buyambien>buy ambien online no rx</a> long ambien cr your system - buy ambien cr online


30/12/2014 6:11am

PHP | Solution - PXxuqTvmhl

<a href=https://www.facebook.com/buyambien>buy ambien</a> buy ambien online mexico - price ambien without insurance


30/12/2014 4:15am

PHP | Solution - YvKzbYFJwD

<a href=https://www.facebook.com/buyxanax>buy xanax</a> 4 bars xanax - xanax kratom


29/12/2014 1:16pm

PHP | Solution - JRlGMXGbiD

<a href=https://www.facebook.com/buyambien>ambien no prescription</a> ambien order purchase - ambien cr goes generic


28/12/2014 5:59pm

PHP | Solution - ZIsbmWTvax

<a href=https://www.facebook.com/buyambien>buy ambien online</a> is ordering ambien online legal - many ambien 10 mg overdose


28/12/2014 1:15am

PHP | Solution - JQEEUqfRzU

<a href=https://www.facebook.com/buyambien>ambien no prescription</a> ambien cr hangover - ambien dosage teenagers


27/12/2014 10:35pm

PHP | Solution - URJxRZKZaG

<a href=http://www.lanepl.org/buytramadol/#55570>tramadol online</a> tramadol withdrawal st john's wort - order tramadol paypal


Post Comment