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

basic upload pdfs and display on resource page problem


Go to End


13 Posts   4061 Views

Avatar
qlex

Community Member, 68 Posts

3 June 2009 at 8:01am

hi,
it is maybe an easy task, but for some reason, i couldnt get it to work. could you help me out with the following.

my objective is:
- create a resource page, where i can upload several pdf's
- the above will allow my client to upload several forms for download,
- the website should display those uploaded pdf's in a table, so its easy for website viewers to download them.

i have DOM installed and have created new page called resources in the CMS. i have uploaded the files to server through the DOM interface.
i have tried to create a Resource.ss template which displayed a table on the website with those pdf's,
but the URL pointing to those, used /wnioski (the actual suffix set in CMS) rather than /assets (which is where the pdf's are located).

could anybody suggest me with the right solution ?
i dont even need categories at the minute TBH.

Qlex

Avatar
UncleCheese

Forum Moderator, 4102 Posts

3 June 2009 at 8:46am

There's a pretty thorough example of this in the 'DataObjectManager Code Examples" sticky post. Are you following that?

Avatar
qlex

Community Member, 68 Posts

3 June 2009 at 9:35am

Indeed i tried.
I have put Resource.php and ResourcePage.php into /mysite and ResourcesPage.ss to /themes/mytheme/templates.
I have no possibility of checking this now, but afair page was empty. Why is the template file not called the same as Resource.php - i.e. Resource.ss ?

Avatar
UncleCheese

Forum Moderator, 4102 Posts

3 June 2009 at 10:06am

A resource is not a page, so it doesn't get a template. Resource extends DataObject, not Page, right?

I think I see the problem. Change the name of ResourcesPage.ss to ResourcePage.ss, so it matches the PHP file ResourcePage.php. Then run a ?flush=1

Avatar
qlex

Community Member, 68 Posts

3 June 2009 at 8:28pm

UncleCheese,
first congratulations on excellent module and second, thanks for being so patient with me.

your suggestion helped me, but still something remains to be corrected.

I have followed your suggestions and after displaying live site i received this code:

<p>Please find below forms for download</p>

<p>&#160;</p>
				
					<h3>First form</h3>
					<p>first description</p>
					
				
					<h3>Second form</h3>
					<p>second  description</p>
					
				
					<h3>Third form</h3>
					<p>third  description</p>

First paragraph is taken from CMS, and all three headings are the actual resources names and descriptions.
However there's no link to the file, so i can click on it and display ?

Somebody suggested i should use this:

<% control Resources %> $Attachment.Link <%end_control %>

but this causes the table to be created with wrong path to files (/wnioski/ instead of /assets)

Any further hints available perhaps ?
Qlex

Avatar
UncleCheese

Forum Moderator, 4102 Posts

4 June 2009 at 1:38am

Can't you just do <a href="$Attachment.URL">Download</a>

Avatar
qlex

Community Member, 68 Posts

4 June 2009 at 1:43am

hi,
using your suggestions from ResourcePage.ss, i added:

<div id="Content">
    <h2>$Title</h2>
	$Content
	<% control Resources %>
	<h3>$Name</h3>
	<p>$Description</p>
	<% control Attachment %>$Player(640,480)<% end_control %>
	<% end_control %>

$Form
$PageComments
</div>

Where should I add your suggestion of <a href="$Attachment.URL">Download</a> ?

Avatar
qlex

Community Member, 68 Posts

4 June 2009 at 1:59am

I adapted the ResourcePage.ss:

<% control Resources %>
		<h3>$Name</h3>
		<p>$Description</p>
		<% control Attachment %><a href="$Attachment.URL">Download</a><% end_control %>
		<% end_control %>

Which gives all the listed resources a "download" option, and all point to my site root.

I guess its the final touch that I need here to get it up and running.

WOuld appreciate any final hints on making sure the template works ok.

Go to Top