I would like to load a footer image depending on the page type. How can I do this?
<% if pagetype = "pagetype" %>
do whatever
<% end_if %>
something like this.
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
I would like to load a footer image depending on the page type. How can I do this?
<% if pagetype = "pagetype" %>
do whatever
<% end_if %>
something like this.
I figured it out.
<% if RecordClassName = "PageType" %>
do whatever
<% end_if %>
I was going to say ClassName but both seem to work, I wonder if there's a difference?
Hi,
I am trying to do something similar and display children if they have the jobpage page type. Any help would be much appreciated. Below is the code I have so far:
--------------------------------
JobHolder.ss
--------------------------------
<div class="typography">
<% if Menu(2) %>
<% include SideBar %>
<div id="content">
<% end_if %>
<% include PageHeading %>
$Content
$Form
$PageComments
<% if JobHolder = JobPage %>
<% control Children %>
<div class="job_posting">
<h2>$JobTitle - $JobLocation</h2>
<p><strong>Closing date: </strong>$ClosingDate.Nice • <strong>Contact: </strong>$ContactPerson • <strong>Phone: </strong>$ContactPhoneNumber • <strong>Mobile: </strong>$ContactMobileNumber</p>
<p><strong>Job Details: </strong>$JobDetails.LimitWordCount(50)</p>
<a href="$Link">Read more...</a></div>
<div class="clear"> </div>
<% end_control %>
<% else %>
<h2>Available vacacnies</h2>
<p>There are currently no vacancies available with CDP. No problem, send us your resume so we can get in touch for any future positions you could be perfect for - <a href="mailto:careers@cdp.co.nz">careers@cdp.co.nz</a>.</p>
<% end_if %>
<% if Menu(2) %>
</div>
<% end_if %>
</div>
------------------------------------
JobHolder.php
------------------------------------
<?php
class JobHolder extends Page {
static $db = array(
);
static $has_one = array(
);
static $allowed_children = array('JobPage','UserDefinedForm');
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeFieldFromTab("Root.Content.Main", "LinkDescription");
return $fields;
}
}
class JobHolder_Controller extends Page_Controller {
}
?>
--------------------------------
JobPage.php
--------------------------------
<?php
/**
* Defines the JobPage page type
*/
class JobPage extends Page {
static $db = array(
'JobTitle' => 'Text',
'JobLocation' => 'Text',
'ClosingDate' => 'Date',
'ContactPerson' => 'Text',
'ContactPhoneNumber' => 'Text',
'ContactMobileNumber' => 'Text',
'JobDetails' => 'HTMLText',
);
static $has_one = array(
'JobDescriptionDownload' => 'File',
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeFieldFromTab("Root.Content.Main", "Content");
$fields->addFieldToTab("Root.Content.JobPosting", new TextField("JobTitle", "Job Title"));
$fields->addFieldToTab("Root.Content.JobPosting", new DropdownField('JobLocation','Job Location',singleton('JobLocation')->dbObject('Location')->enumValues()));
$fields->addFieldToTab("Root.Content.JobPosting", new DatePickerField('ClosingDate','Application closing date'));
$fields->addFieldToTab("Root.Content.JobPosting", new TextField("ContactPerson", "Contact person"));
$fields->addFieldToTab("Root.Content.JobPosting", new TextField("ContactPhoneNumber", "Contact phone number"));
$fields->addFieldToTab("Root.Content.JobPosting", new EmailField("ContactMobileNumber", "Contact mobile number"));
$fields->addFieldToTab("Root.Content.JobPosting", new FileIFrameField('JobDescriptionDownload', 'Upload a PDF of the job description'));
$fields->addFieldToTab("Root.Content.JobPosting", new HtmlEditorField("JobDetails", "JobDetails"));
return $fields;
}
}
class JobPage_Controller extends Page_Controller {
}
?>
Does my JobHolder.php need the following:
static $has_many = array(
"Jobs"=>"Job"
);