Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

Preview: DataObjectManager module


Go to End


379 Posts   95930 Views

Avatar
pcbender

Community Member, 20 Posts

10 March 2009 at 5:02am

Thanks for the reply.

The call to $Attachment.Type returns no value in the example below:

<% if Resources %>

<ul>
<% control Resources %>
<li><a href="$Attachment.URL">Download $Name $Attachment.Size and $Attachment.Type and $Category</a></li>
<% end_control %>
</ul>
<% end_if %>

Off Topic:

Is there some way to programatically identify the fields and methods available to a view or template? For example:

<% if Resources %>
$ShowMembers
<ul>
<% control Resources %>
<li><a href="$Attachment.URL">Download $Name $Attachment.Size and $Attachment.Type and $Category</a></li>
<% end_control %>
</ul>
<% end_if %>

The $ShowMembers call would return a list of members callable from the view.

THanks,

PC

Avatar
UncleCheese

Forum Moderator, 4102 Posts

10 March 2009 at 5:19am

Edited: 10/03/2009 5:23am

As far as the Type property is concerned, I was just taking a guess. I'm not really sure of all the properties available for the File class. Check the docs/API.

By creating a function such as $ShowMembers, you're breaking the MVC pattern by bundling presentation into your controller. That's what control blocks are for.

<% control Members %>
<li>$Name</li>
<% end_control %>

Edit: sorry. I misread your request, thinking you meant Members as in users. I would look at the "Built in template controls" topic in the docs first. Anything beyond that is accessible in either the model or controller of your page or object as a property or method.

public $MyProperty = "foo"
public function MyFunction() {
return "bar";
}

$MyProperty $MyFunction

returns "foo bar"

Further, any named relation in your model gets a magic method.

$has_many = array ('Objects' => 'MyClass');

now grants you the function

$this->Objects();

Or on the template:

<% control Objects %>

Avatar
pcbender

Community Member, 20 Posts

10 March 2009 at 6:40am

Thank you very much. You are a tremendous asset to the SS community.

BTW, it is $Attachment.FileType

PC

Avatar
drye

Community Member, 49 Posts

10 March 2009 at 4:59pm

UncleCheese, Have you ever thought about modifying the popup to have the save button on the bottom next to the close button? Just a random thought.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

11 March 2009 at 2:53am

Good idea, but unfortunately, not likely to happen. The save button needs to be in the iframe and the close button needs to be on the popup window itself. The next enhancement I make to the FileDataObjectManager, and by transference, the ImageGallery, is to add a "Stop Captioning" button next to save that will give the users a more intuitive way to stop the post-upload walkthrough if they wish.

Avatar
drye

Community Member, 49 Posts

14 March 2009 at 5:18pm

Uncle Cheese, Noticed that a boolean displays in the table as a 1 or 0. Could this be a checkbox instead? Possibly even editable from the table view?

Avatar
UncleCheese

Forum Moderator, 4102 Posts

14 March 2009 at 6:44pm

That's true with any TableField. Make sure you build a custom getter.

static $db = array (
'MyBool' => 'Boolean'
)

public function getMyBool()
{
return $this->MyBool ? "Yes" : "No";
}

Avatar
drye

Community Member, 49 Posts

14 March 2009 at 7:03pm

Edited: 14/03/2009 7:10pm

Thanks, Actually I was already trying something like this:

	public function getPublish()
	{
		$field = new CheckboxField('Publish','Publish this content?',$this); [EDIT]
		$field->useLabelLeft(false); 
		return $field;
	}

But it only displays the checkbox, it doesn't accept the changes...
http://pastie.org/415959

Go to Top