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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

creating a thumbnail navigation for client portfolio?


Reply

8 Posts   1859 Views

Avatar
patte

20 January 2009 at 10:24pm Community Member, 63 Posts

Hi,

I am new to silverstripe trying to evaluate it as our future cms. I really like the admin interface and the MVC concept of sapphire/silverstripe. I think it will fit all my needs, hopefully ;-)

I have a question regarding my first website with a client portfolio page - like the StaffHolder/StaffPage in the SS tutorial - but with a thumbail navigation on the left side.

Can someone please explain how to iterate through my ProjectPages (or the StaffPages) using a thumbnail navigation with a class="current" for the active state?

I have tried to replace the Link "$MenuTitle" with "$Photo.SetWidth(50)" which i have created in ProjectPage.php but this ends in a Fatal error: Call to a member function XML_val() on a non-object in Layout.ProjectPage.ss

<% control Menu(2) %>
<li class="$LinkingMode"><a href="$Link" title="Go to the $Title page">$Photo.SetWidth(50)</a></li>
<% end_control %>

Can someone give me a tip how to solve this?

Thanks much in advance!
patte

Avatar
Carbon Crayon

21 January 2009 at 12:45am Community Member, 598 Posts

Hi Patte, welcome to silverstripe :)

As far as I can see that should work, could you post the rest of your code?

cheers

Aram

Avatar
patte

21 January 2009 at 9:38pm (Last edited: 21 January 2009 9:42pm), Community Member, 63 Posts

Hi aram,

I think I have two problems with that navigation:

1. when using the tutorial navigation code within my PortfolioPage.ss it shows only the current page, not all the pages within the same level.

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


Because this is all new to me - shouldnt the PortfolioPage navigation have to "look up" one level and than list all the childs with type of PortfolioPage? Isnt the 'control Menu(2)' some kind of static because of its level dependency?

2. the thumbnail. Within PortfolioPage.ss I am succesfully using '$Photo.SetWidth(250)'. In that template I am trying to use the thumbnail navigation using 'control Menu(2)'. This gives me an error.

Fatal error: Call to a member function XML_val() on a non-object in C:\WINDOWS\Temp\silverstripe-cacheD--Internet-wamp-www-silverstripe\.cacheD..Internet.Wamp.www.silverstripe.themes.my-website.templates.Layout.PortfolioPage.ss on line 217

<% control Menu(2) %>
<li class="$LinkingMode"><a href="$Link" title="Go to the "{$Title}" page">$Photo.SetWidth(50)</a></li>
<% end_control %>

Any idea?

Onother question... where would be the best place to put my own templates? I am using SS 2.3 and I am a bit confused with the file structure. There is a 'mysite' with the _config.php referring to my theme. Do I have to put my 'code' within the 'mysite' folder and the templates in the theme folder? Or can I put everything in one folder, for example 'my-domain' which would contain _config.php ?

Do you know any explanation for the theme/mysite folder thing? When do I use a theme?

Thanks much for any tip !

patte

Avatar
Carbon Crayon

22 January 2009 at 12:05am Community Member, 598 Posts

ok, the file structure is really down to you. I use the mysite/code and mysite/javascript for all my .php and .js files and I use themes/myTheme/css, themes/myTheme/images, themes/myTheme/templates for my theme files. As far as I know this is the recommended way to do it, but you can just as well use mysite/css, mysite/images and mysite/templates for your theme. These folders will always overwrite the themes directory if you have files in both.
Although I've never tried I think having your own foldername with a _config.php in place of the mysite folder should work fine.

Now to your navigation problem.....it seems very strange indeed as the Menu(2) should indeed show all the pages of the current level (unless 'show in menu' is unchecked on each page in the CMS). Does your menu(2) work in other sections? For example can you make a hierachy of normal 'Page' page types? If you can then obviously there is something funny going on with your PortfolioPage type, in which case could you post your entire code for your template and .php file on to something like pastie.org so we can take a look at whats going on.

I suspect the Image problem is related to this so lets get the menu workingand then see if the images work. If you can use $Photo on your page then you should be able to use it in a <% control %> block too.

Avatar
patte

22 January 2009 at 7:19am (Last edited: 22 January 2009 7:29am), Community Member, 63 Posts

Hi aram,

thanks much for your help.

I started again with a clean install of SS with blackcandy theme. From the [url=http://doc.silverstripe.org/doku.php?id=tutorial:2-extending-a-basic-site/]Tutorial 2[/url] I take the code for StaffHolder and StaffPage - this should be nearly the same structure as for my Portfolio pages.

Everything works as expected - on the StaffHolder the content is listed and on the StaffPages there are the Photos. Like shown in the tutorial ;-)

Now I would like to have the navigation showing thumbnails of those Photos instead of $MenuTitle.XML...

<li class="$LinkingMode"><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode levela"><span><em>$MenuTitle.XML</em></span></a>

This is the "normal" navigation using the titel of StaffPage. How can I make it showing thumbnails of StaffPage Photo instead? Just replacing $MenuTitle.XML with $Photo results in an error.

patte

EDIT: perhaps I am not able to use 'control Menu(2)' in general for displaying images?

Avatar
Carbon Crayon

22 January 2009 at 11:43am (Last edited: 22 January 2009 11:44am), Community Member, 598 Posts

hmmm, I tested this and it works fine for me. I'm using 2.23, but it can't have changed in 2.3.

What is the .XML stuff after menu title for? I think that might be something to do with it. Do you have a XML definition as the first line of your Page.ss? Try removing it and see if that fixes it. Do you need it to be an XML page ?

Avatar
patte

22 January 2009 at 9:07pm Community Member, 63 Posts

strange, there is really nothing special in my template. It is exactly as described in the tutoral.

I think Ill just start to go on with our first project using siverstripe. Perhaps there is an error with my wamp configuration - when I am at the point building my lovely thumbnail navigation it will work, hopefully ;-)

Avatar
not2dumb

13 July 2009 at 7:39pm (Last edited: 23 July 2009 9:56am), Community Member, 16 Posts

hi there,
actually i'm having the exactly same problem.
used the technique as mentioned in the staff/news tutorial for two different templates.
while one is working fine, the second (used to list the ensemble with thumbnailed pics) throws the same errormessage.

what i found out is the following:
as long as i use the "SETWIDTH" function in my template i get this errormessage, if i leave this out (only referring 2 the pic with $Fuesse) everything works great, which made me think of a file permission problem with the "_resampled" folder inside my "assets/picture" folder.

but when i compare the rights between this and other "_resampled" folders (all set to "755") i can't find any differences between them. and there is norhing to find about in the doc's!

i've already tried to delete this folder and upload the pics again without any success. so this might be an issue for a trouble wth the user rights in the DB?!

finally i found out that the page works perfectly if i'm loggen into the cms an visit the page via the preview function inside the cms. after i did that the page works perfectly, as long as i stay logged on to the cms.

so has anyone occured the sam problem before and has any cool idea how to solve??

thanx

trouble solved:
a bit embarassing, but a simple <% if Image %> helped a lot...