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.

Data Model Questions /

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

Inject controller action into menu


Go to End


2 Posts   1574 Views

Avatar
r0nn1ef

Community Member, 6 Posts

7 July 2011 at 2:19pm

I've been working with SS for awhile now, but for the life of me can not figure out how to inject a page controller action into the menu system.

For example, I have a TeamPage with the url of /team that shows photos and info of the officers and squads. I also want to use the same page for the individuals' photos. So the URL for that page would actually be /team/individuals. I can create the page controller action fine, but getting it in the menu and labeled "Individuals" is where I'm running into problems. I've tried a virtual page and redirector page, but they don't let me choose actions from an existing page.

Anyone have a place for me to start on this one?

Thanks in advance. :)

Avatar
martimiz

Forum Moderator, 1391 Posts

8 July 2011 at 4:41am

Assuming StaffMember to be the DataObject for individual persons, you need is a Link() function in StaffMember that creates a unique link based on the Link of the page it belongs to. You can then use that link in a <% control StaffMembers %> loop within your menu.

There's a nice tutorial on the subject here:

http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-1-keeping-it-simple/