7911 Posts in 1354 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » [SOLVED] Drill down on frontpage
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | Next > | |
| Author | Topic: | 1897 Views |
-
Re: [SOLVED] Drill down on frontpage

27 August 2009 at 8:41am
If I understand the functionality you want, I would render all the content on the page and then hide and show elements of it using jQuery but I'm more comfortable with JavaScript than PHP.
Something like this: http://roshanbh.com.np/examples/exapandable-panel/
Here is the Source
http://roshanbh.com.np/2008/03/expandable-collapsible-toggle-pane-jquery.htmlThere are more fancy versions of this but this was the first one a quick Google search revealed
-
Re: [SOLVED] Drill down on frontpage

27 August 2009 at 9:03am
Ohh.. I see now. Thank you for clearing that up, zenmonkey.
Here's a jQuery script I use for all my blind-down toggles.
toggle.js
$(function() {
$('.toggle-content').hide();
$("a[@rel=toggle]").click(
function() {
$(this).toggleClass("open");
$("#toggle-content-" + this.id.replace('toggle-','')).slideToggle("fast");
return false;
}
);
}
);Usage:
<a rel="toggle" id="toggle-$ID">Show details</a>
<div id="toggle-content-$ID" class="toggle-content">Some more content here...</div>Where $ID is a unique number that will be the same on a block of content and its corresponding link.
-
Re: [SOLVED] Drill down on frontpage

27 August 2009 at 9:05am
Maybe the jquery-trick can help, I'll give it a try,
But trying to be a bit more clear. I'm converting a custom-made site (cake-php) to silverstripe, so I can show the current site:
http://www.savedbythebell.be/kaart/provincie/West-VlaanderenThis is exactly what I want to reach: a list of schools, and when clicking the name, getting the details,
thanks for your patience
-
Re: [SOLVED] Drill down on frontpage

27 August 2009 at 9:38am Last edited: 27 August 2009 9:40am
I don't think you'll need jQuery for this. SilverStripe should handle this just fine:
A) place the following code in your ActionPage_Controller classprotected $detailData;
public function details(){
// get the id parameter
$id = intval(Director::urlParam('ID'));// get the DataObject with the given ID and store it in $detailData
$this->detailData = DataObject::get_by_id('Action', $id);// return empty array, so that the correct templates are being used
return array();
}// accessor for the detail data
public function DetailData(){
return $this->detailData;
}B) after that, you should be able to call the "details" method, by appending details/id to your page-url, where id is your DataObject ID. Example: http://yoursite.com/your-action-page/details/5
The method will fetch the DataObject with the given ID and assign it to the detailData member-variable. This can then be accessed in the Template using $DetailData.C) The beauty of this is, that you can use a custom Template (or Layout) file for the details page. Just name it: ActionPage_details.ss. In this template you can then call something like:
<% control DetailData %>
... access all memebers of the Action DataObject here ...
<% end_control %>There are actually several possible solutions to this problem, this is just one of them (that works for me). I think it's also possible to directly return data to the template renderer by returning some special formatted array (instead of an emtpy one). But the proposed method works equally well.
-
Re: [SOLVED] Drill down on frontpage

27 August 2009 at 11:31am
That's the thing, though. There is no DataObject. The school name is just free text. If it were a has_one relation to school, you could use the /details/$ID approach, but I'm not sure that's what he's looking for.
-
Re: [SOLVED] Drill down on frontpage

27 August 2009 at 4:26pm
@banal tnx a lot! This is what I was looking for and worked like a charm.
@UncleCheese maybe it was unclear, but there is a DataObject (Actions), $organisatie was just one argument of it. Tnx for thinking with me. -
Re: [SOLVED] Drill down on frontpage

28 August 2009 at 12:45am
Hi!
Now that's off-topic, but I tried the toggle.js JavaScript exactly as described by UncleCheese in one of my pages, adding this to Controller:
function init() {
parent::init();
Requirements::javascript('jsparty/jquery/jquery.js');
Requirements::javascript('mysite/javascript/toggle.js');
}Both files are being loaded, but Firebug says: $(".toggle-content") is null
The class toggle-content is there, as I use the same HTML code as UncleCheese. What can be wrong ?
Thanks in advance,
Juan -
Re: [SOLVED] Drill down on frontpage

28 August 2009 at 1:08am
I find it myself!
I had to wrap the jQuery code as recommended in http://doc.silverstripe.org/doku.php?id=jquery
;(function($) {
$(document).ready(function() {
$('.toggle-content').hide();
$("a[@rel=toggle]").click(
function() {
$(this).toggleClass("open");
$("#toggle-content-" + this.id.replace('toggle-','')).slideToggle("fast");
return false;
}
);
})
})(jQuery);I would like to know why that worked, since I have already added $(document).ready without success…
| 1897 Views | ||
| Go to Top | Next > |


