SSbits - Home page
Site by Carbon Crayon
Submit a Post >

Tutorials - Big bits of code to help you do more

DataObject as Pages: The Module

SSBdataobjectsaspagesmodule

 Source files  Demo (admin/pass)

It's been a while since we published the DataObject as Pages series of tutorials, which have proved to be particularly popular. At Aab Web we use those techniques regularly as a way to allow our clients to mange large amounts of flat content or content that is distributed in multiple places throughout a site. Although the final implementations in each project are often varied and bespoke, they all start with the basics outlined in those tutorials, so it made sense for us to build a starting point to work from (and include some more complex features at the same time). That starting point is this module, catchily entitled: DataObject as Pages.

About the Module

Get the Module on Github: DataObjects-as-Pages: The Module

So first things you are probably wondering is 'what can I do with this module'. Well once you have extended the classes in the Module you will have a fully functioning DataObject as Page system with

Features

  • Basic Versioning, with Stage & Live versions of each Data Object, managed in Model Admin.
  • Searchable DataObjects, allowing instant implementation into a search dependent site using the DoapSearchForm and Controller.
  • Fully extendable listing page type, allowing implementation of filtering systems and tags/category models
  • Easy implementation: Simply extend the 3 classes, add a couple of static values and you are ready to go!
  • URLSegment based DataObjects with MetaTitle and Description built in.

So without further ado, you can grab the code from the module here: https://github.com/arambalakjian/DataObjects-as-Pages and then follow the instructions below, where we'll first take you through the most basic implementation, then show you how you can extend it to do some really cood things, like we did on www.mymuswell.com, where all the Articles, Places, events and Deals are based on DataObjects.

Basic Setup

Ok, so you probably want to just get going with this so you can have a play around. We'll here are the 3 files you need to create, just like when doing the Part 2 tutorial, only this time without any actual logic!

mysite/code/ProductListingPage.php (Extends DataObjectAsPageHolder

 

class ProductListingPage extends DataObjectAsPageHolder 
{

}

class ProductListingPage_Controller extends DataObjectAsPageHolder_Controller 
{
	//This needs to know be the Class of the DataObject you want this page to list
	static $item_class = 'Product';
	//Set the sort for the items (defaults to Created DESC)
	static $item_sort = 'Title ASC';
}

mysite/code/Product.php (Extends DataObjectAsPage)

class Product extends DataObjectAsPage 
{
	//The class of the page which will list this DataObject
	static $listing_class = 'ProductListingPage';
	//Class Naming (optional but reccomended)
	static $plural_name = 'Products';
	static $singular_name = 'Product';
}

mysite/code/ProductAdmin.php (extends DataObjectAsPageAdmin)

class ProductAdmin extends DataObjectAsPageAdmin {
   
	public static $managed_models = array(
		'Product'
	);

	static $url_segment = 'products';
	static $menu_title = 'Products';
}

And that's it! You now have a fully functioning, versioned, searchable DataObject as Page implementation! You can now carry on as normal and add all the fields you want to Product, implement your templates (see below) and see where you can take it.

Templates

You will see there are 2 very basic templates provided with the module, DataObjectAsPageHolder.ss and DataObjectAsPageHolder_show.ss. These are just to get you started but should show you how to setup your own. The modules show function makes use of SilverStripes automatic template finder which follows the naming convention [PageClass]_[action].ss. So for this module our [action] is 'show' meaning we just need to add a second template with _show on the end of our standard template for displaying the DataObject detail page.

Following this logic, if we wanted to create a template for our Products in the code above, we would have the following:

themes/mytheme/templates/Layout/ProductListingPage.ss (the page to list all the Products)

<div class="typography">
	
	  	<% include BreadCrumbs %>
		
		<ul>
		<% control Items %>
			<li>
				<h2>$Title</h2>
				<p>$Content.FirstParagraph</p>
				<a href="$Link">View</a>
			</li>
		<% end_control %>
		</ul>
</div>

<% control Items %> is used to cycle through the DataObjects which are being listed on this page. If you check the 'Use Items as children' under the Behavior tab of the Listing Page, the items will also be returned as <% children %>, allowing you to include them in Menu's etc. You can also pass in an arberary limit to Items(), for example <% control Items(5) %> would give you the first 5 products.

themes/mytheme/templates/Layout/ProductListingPage_show.ss (the actual product page)

<div class="typography">

	<div id="Breadcrumbs">
		<p>$Breadcrumbs</p>
	</div>
		
	<% control Item %>
		<h2>$Title</h2>
				
		$Content
	<% end_control %>

</div>

On this page we use <% control Item %> to go into the current DataObject and display it's data, in this case just the default $Title and $Content.

Extending the Listing Page to do Fancy things

The Listing page is really the core of the module. It fetches and displays the relevent DataObjects and it's here that you can start extending in order to gain more control over how those DataObjects are returned by the Items function. We have built the module to allow you to extend the Listing Page functionality without having to re-write the core functions (in most cases). Primrily this section focuses on the functions you can use to manipulate the DO's that are retreived, but in a future tutorial we will look at creating specific functionality such as a URL based filtering system.

Pagination

Pagination is built into the Module, and enabled by default. You can find the options to change the page size and disable it under the Behavior tab of your listing page, along with the switch to return your Items as Children of the listing page.

 

Manipulating the WHERE

	/*
	 * Overload the SQL WHERE builder
	 */
	public function getItemsWhere() 
	{
		//Use this function to return a custom filter to the Items() function
		return "Date > CURDATE";
	}

By adding a getItemsWhere() function to your ListingPage_Controller, you can manipulate the Where statement that is used when collecting all the DataObjects to list on this page. This allows you to build filtering into your page, dynamically adding extra conditions to the SQL. As a basic example you could return Date > CURRDATE(); if your DataObject had a Date field and you only wanted to show DataObjects where this date was after today.

 

Manipulating the Sort Order

As well as using the static $item_sort as detailed above, there is also a function which you can use to set the sort more dynamically:

	/*
	 * Overload the Sorting of Items
	 */	
	function getItemsSort()
	{
		return "MyField DESC";
	}	

Manipulating the Join

	/*
	 * Overload the Join builder
	 */	
	function getItemsJoin()
	{
		return [JOIN STATEMENT];
	}

Pretty self explanitory, but here you can add a join to the SQL in the Items() function, so if you needed to filter on a related objects field, you could add the filter in the getItemsWhere() function then return the required Join here.

 

So there you have it, the first release of what will hopefully prove to be a useful module. Obviously it's in it's early days so if anyone has any suggestions as to how to improve it please let us know!

Aram Balakjian avatar

Aram Balakjian

Aram is a web developer running London based agency Aab Web. He has a strong passion for developing attractive, usable sites around the SilverStripe CMS.

  • FullWebService
    24/01/2012 1:10pm (3 years ago)

    Looks intersting and useful. I'll try it out this week.

  • RoyalPulp
    24/01/2012 2:44pm (3 years ago)

    Hi Aram,
    wonderful, I have been using "Dataobject as a Page" in many projects now and I will test this module next week.

    There's one important piece of code that I use in addition, to write the DataObject-Pages into the sitemap.xml:
    http://www.silvercart.org/blog/dataobjects-and-googlesitemaps/

    Hendrik

  • Aram Balakjian
    24/01/2012 2:50pm (3 years ago)

    RoyalPuly - good point. There is already an absoluteLink() function on the DataObjectAsPage class, so you can use the code on silvercart.com to make it work, but it would be much better to have it out the box, so I will look into the best way to do that.

    Aram

  • Xurk
    25/01/2012 1:02pm (3 years ago)

    Thanks for sharing, this sounds really interesting!

    We regularly use the "DataObjects as Pages" method for our websites and the fact that it is now a module not only facilitates the task of implementing it, but (perhaps the best feature) now also includes DataObjects in the search results... very nice.

    Recently we gave UncleCheese's RemodelAdmin a shot which is actually the reverse of this - "Pages as DataObjects" comes pretty close to describing it. Great to know that we can now pick one of the two methods depending on what the project calls for, and not loose any functionality of the class we're attempting to mirror :-)

  • Matty Balaam
    27/01/2012 9:43am (3 years ago)

    I realise this isn't an issues at the moment and won't be for a while, but I'm guessing this won't be compatible with SS3 as GridField is going to replace DataObjects.

    Do you think you'd have plans to update this module at that point? Do you think it will be an easy enough job to do, or a complete rewrite?

  • Aram Balakjian
    27/01/2012 9:47am (3 years ago)

    Hi Matty,

    As I understand it, Grid Field is going to replace ComplexTableField, so won't effect this module.

    However I will need to update it to accomodate the new DataList class which will supercede the DataObjectSet.

    I'll do that once I get familiar with the new changes, but I don't expect it to be a hugely complex task :)

    Aram

  • Matty Balaam
    27/01/2012 3:03pm (3 years ago)

    Ah, brilliant, great to know this module will be future proof, thanks for your clarification.

  • Richard Rudy
    27/01/2012 7:10pm (3 years ago)

    Great Stuff Aram, just popped on to look over the tutorial and lo and behold its wrapped and ready to go

    Thanks

  • jakmax
    31/01/2012 10:07pm (3 years ago)

    Hi Aram,

    i create product page and product, it's all ok.
    But i need to have comments in all dataobject page.
    I add $Pagecomments in my .ss template, but when i save it posts same comment in all pages.. can you help me? my code is post here
    http://www.silverstripe.org/dataobjectmanager-module-forum/show/19101
    sorry for my english, i'm from italy
    thanks
    bye, max

  • fghjfghgh
    31/01/2012 10:49pm (3 years ago)

    Hey Aram, great module!
    I'm creatjng a portfolio with it and it seems the pagination controls are missing from the template? Also I would like to see an example of category/tag filtering if anyone could help me there.
    Thanks

  • Aram Balakjian
    31/01/2012 10:55pm (3 years ago)

    @jakmax - See forum reply, unfortunately not a stright forward task (until we release a module ;).

    @Mattin4D - It looks like it's there, line 20 of DataObjectAsPageHolder.ss: https://github.com/arambalakjian/DataObjects-as-Pages/blob/master/templates/Layout/DataObjectAsPageHolder.ss

    Aram

  • fghjfghgh
    31/01/2012 11:03pm (3 years ago)

    ok thanks I should have checked, I downloaded the day you posted this.

  • Aram Balakjian
    31/01/2012 11:04pm (3 years ago)

    Ah yea, I have added it since, keep checking back too as I will be continually updating it :)

    Aram

  • jakmax
    01/02/2012 8:36am (3 years ago)

    Ok Aram,
    thank you very much for your reply.
    ok so if I understand correctly I have to create a form that records on a database (like UserForm) and pass an hidden field with the ID of the DO and then invoke in the template a query with the comments that have the id of the DO...

  • Aram Balakjian
    01/02/2012 9:11am (3 years ago)

    Hi Jakmax,

    Yep pretty much, when you pass the ID of the DO, in the submission function, you can relate that comment to that DO using a has_one on the Comment to a has_many on the DO. Then, say your has_many was called 'Comments' then you just call <% control Comments %> in the template and it will return all the comments accociated with that page.

    Aram

  • jakmax
    01/02/2012 10:08am (3 years ago)

    ok I think I understand ;-)
    I'll try tonight and then I can tell you ..
    Meanwhile, thank you very much

    Jakmax

  • Bart van Irsel
    02/02/2012 8:52pm (3 years ago)

    Hi Aram,

    Thanks a lot for sharing this at exactly the right moment.
    We're going to look into this for our project which can use this tomorrow!

    Cheers,

    Bart

  • Aram Balakjian
    02/02/2012 9:16pm (3 years ago)

    @bart - Great! Let me know how you find it :)

    Aram

  • jakmax
    03/02/2012 12:06am (3 years ago)

    Hi Aram,
    I almost solved, but when I try to pass the hidden field I get the following error:
    [Notice] Trying to get property of non-object
    my hidden field is:
    new HiddenField ('ProductID', 'ProductID', $ this-> getCurrentProduct () -> ID)
    where I'm wrong?
    Thanks

    jakmax

  • Aram Balakjian
    03/02/2012 1:19pm (3 years ago)

    @jakmax - ahh yea, you need to wrap it in an if() because when the form submits, it doesnt actually have a URl ID anymore, try this:

    if($product = $this->getCurrentProduct)
    {
    $fields->push(new HiddenField('ProductID','ProductID',$product->ID));
    }

  • jakmax
    03/02/2012 2:12pm (3 years ago)

    i tried:

    $fields = new FieldSet(
    new TextField('Nome', 'Nome *'),
    new TextareaField('Commento', 'Commento *'),
    /*new HiddenField('ProductID','ProductID','88'),*/

    new PhpCaptchaField('Captcha','')

    );
    if($Product = $this->getCurrentProduct())
    {
    $fields->push(new HiddenField('ProductID','ProductID',$Product->ID));
    }

    but the value in DB is 0

    :-(

  • jakmax
    03/02/2012 2:19pm (3 years ago)

    ok great Aram!

    i change my code and it's work great!!

    function PostComments() {



    // Create fields
    $Params = Director::urlParams();
    $fields = new FieldSet(
    new TextField('Nome', 'Nome *'),
    new TextareaField('Commento', 'Commento *'),
    new HiddenField('ProductID','ProductID',''),

    new PhpCaptchaField('Captcha','')

    );
    if($Product = $this->getCurrentProduct())
    {
    $fields->push(new HiddenField('ProductID','ProductID',$Product->ID));
    }
    // Create action
    $actions = new FieldSet(
    new FormAction('SendComment', 'Invia')
    );

  • jakmax
    03/02/2012 2:38pm (3 years ago)

    Thank you very much Aram!

  • Aram Balakjian
    03/02/2012 2:40pm (3 years ago)

    @ jakmax - no problem! Glad you got it working :)

  • Todd
    04/02/2012 11:35pm (3 years ago)

    Aram --

    Thanks for the great module. It's an awesome point to build from. (An aside: www.mymuswell.com is a fantastic site. Well done.)

    I just noticed that if you try to have a db field in an object with the same name as the object, it breaks the SQL queries the module uses. (I had a Quote object that had an HTML db field called Quote and another field called Author.) Probably a small thing since it's likely not best practice for a field in an object to share the object's name. Changing the field name solved the problem.

  • Thomas Apfelbacher
    09/02/2012 9:42am (3 years ago)

    Hi Aram,

    thanks again for a nice and useful tutorial.
    FYI: The demo login gives an error: [User Warning] Cookie 'alc_enc' can't be set. The site started outputting was content at line 2 in /.../demo_site/local-config.php

    Greetings. Pipifix

  • Aram Balakjian
    09/02/2012 9:52am (3 years ago)

    Thanks Thomas, that's fixed now :)

  • Adam Stead
    11/02/2012 2:48pm (3 years ago)

    This is a great little module, we regularly use DataObjects as pages, now this module will streamline that progress. Hopefully we will be able to contribute more to it as we use it.

  • Daniel Schweiger
    17/02/2012 7:45am (3 years ago)

    hi,
    thx for sharing this module.

    Is it possible to manage the DataObjects from a own tab on the page, not via ModelAdmin?

  • Matty Balaam
    24/02/2012 8:14pm (3 years ago)

    I've been playing with this today, but run into a small problem. I can't get the child pages to show in nested navigation, unless I'm actually on the 'holder' page. Is this expected behaviour?

  • Matty Balaam
    29/02/2012 2:15pm (3 years ago)

    I've ran into another interesting issue.

    As well as only showing the objects as menu items when I'm on a holder page, it I go ahead and extend DataObjectAsPage with a second class, every object for both appears on either holder page.

  • Thomas Apfelbacher
    08/03/2012 9:06pm (3 years ago)

    Hi Aram,
    thanks again for this plugin. I've got two questions.
    1.) Filter DOs by an enumfield

    My DOs are persons. Their are categorized by orginisations they work in. (org1…org4). On my PersonListingPage i want to separate the items in different tabholder (Bootstrap UI Tabs). How to filter these items? Do i have to use function getItemsJoin()? And how to declare the JOIN statement?

    2.) I receive an error by searching a title of these persons. "....WHERE (MATCH (Title,MetaDescription,Content) AGAINST ('Musik*' IN BOOLEAN MODE)) Column 'Title' in where clause is ambiguous". The whole Sitesearch is broken. Whats wrong?

    Thanks, Thomas

  • Thomas Apfelbacher
    12/03/2012 3:11pm (3 years ago)

    It' me again.

    I'll answer my first question.
    The simple solution to this problem is GroupedBy. The code should looks like this.
    <ul class="tabs-content">
    <% control Items.GroupedBy(Orga) %>
    <li class="personCategories">
    <ul>
    <% if Children %>
    <% control Children %>
    <li><span>$Title</span>
    <a class="personDetailLink" href="$Link"><i class="icon-eye-open"> </i>see details</a>
    </li>
    <% end_control %>
    <% else %>
    <p>There are no persons in this category, yet.</p>
    <% end_if %>
    </ul>
    </li>
    <% end_control %>
    </ul>
    But it seems that unpublished data items will rendered too. i've got no glue whether this is a misbehavior of the doap-module or the <% if Children %> is misinterpreted.

    Thomas

  • Thomas Apfelbacher
    27/03/2012 12:34pm (3 years ago)

    Sorry, for messing up your comments section. But i want to answer myself for all the folks out there running in the same issue.

    Broken Search: I gave the dataobject 'Person' a database column 'Title'. But thats allready used by the dataobjetcs-as-pages class itself. The following attributes are restricted:
    'Status', 'URLSegment', 'Title','MetaTitle','MetaDescription' ,'Content'.

    Thomas

  • Richard Rudy
    01/04/2012 4:44pm (3 years ago)

    Aram, is it possible to embed a DataObjectManager into a DataObjectAsPage? I have a $has_many relation on my DOAP, but once I replace the default TableList with an DOM I can add the DataObjects, but once I try to view them I get and error on ViewableData.php

    Warning: "strpos() expects parameter 1 to be string, array given" at line 268 of /Applications/MAMP/htdocs/X/sapphire/core/ViewableData.php

  • Aled Brown
    08/04/2012 7:31pm (3 years ago)

    Does this module allow easy translations of the sub pages for multi-lingual websites?

  • Richard Rudy
    15/04/2012 9:15pm (3 years ago)

    Just wondering how I'd call a DataObjectAsPage with AJAX, placing the usual if(Director::is_ajax()) and index call in the DataObjectAsPageHolder doesn't seem to work. It renders with the default DataObjectAsPageHolder_show for the Object in question

  • Aram Balakjian
    16/04/2012 10:41am (3 years ago)

    Hi Rich,

    You will need to use the $this->renderWith(array('MyAjaxTemplate')); call inside if($this->is_ajax()){} so that it doesn't render a complete page.

    Aram

  • Richard Rudy
    17/04/2012 12:37am (3 years ago)

    Aram, I have the following in the index() of MyDataObjectAsPageHolderPage_Controller:
    if(Director::is_ajax()/* || $_GET["ajaxDebug"]*/) {
    return $this->renderWith(array('MyDataObjectAsPageHolderPage_ajax'));
    } else {
    return Array();
    }

    When I do ?debug_request the template specified in the renderWith() doesn't even show in the array. And if I call $isAjax is ajax in the template it shows 1

    Thanks for any direction you can provide

  • Michael
    02/06/2012 1:20pm (3 years ago)

    Great module! Im having trouble using the doapsearch though... How would you call the sear on the page? $doapsearchform or?
    Do you need to create a page template to receive the results?
    Thanks

  • Richard Rudy
    09/06/2012 8:48pm (3 years ago)

    Hey Aram, any plans on tweaking this for SS3. I've started slowly chunking away at it removing code that incompatible and trying to convert stuff to the new ORM

  • Aram Balakjian
    18/06/2012 7:05pm (3 years ago)

    Hi Richard, I will definitely look to update the module once I find some time, most likely it will be when we start using SS3 at Aab Web for production projects and need the module ourselves.

    Aram

  • Tate
    19/09/2012 1:15am (2 years ago)

    How does this scale to SS3

  • AntonyJay
    20/09/2012 1:52am (2 years ago)

    Hi Aram,

    I've just started playing around with this and got it working successfully with a modified CsvBulkLoader, however I need to be able to clear down existing DataObjects and publish the new CSV DataObjects on upload.

    Any ideas on how I can do that?

    Antony

  • graham
    26/09/2012 9:23pm (2 years ago)

    Hi Aram,

    Great module with a lot of potential.

    Does anyone have advice on creating a controller that will work on a second page type. My specific intent is to display a small number of the most recent entries on the home page in addition to the listing page described.

    Any pointers appreciated!

    Graham

  • Aram Balakjian
    27/09/2012 4:19pm (2 years ago)

    Hi Graham,

    This is very simple, as all DataObjectAsPage items are still DataObjects at heart so you can simply something like this in a function in HomePage_Controller:

    return DataObject::get('MyDataObjectClass', Null, 'Created DESC', Null, 5);


    Hope that helps

    Aram

  • graham
    30/09/2012 7:40pm (2 years ago)

    Thanks Aram!

    I knew it was something like that and I did eventually figure it out just before I checked in again.

    As a newcomer, it's really helpful having so many people willing to give a few moments to offer pointers/advice. I hope to do the same once I become more familiar with things.

    Much appreciated!

    Graham

  • webspilka
    10/12/2012 2:37pm (2 years ago)

    I have next error
    [Notice] Undefined variable: table
    in code
    $results = $itemClass::get()->where($filter);
    60
    61 if($joins)
    62 {
    63 foreach($joins as $type => $join)
    64 {
    65 if($results->hasMethod($type))
    66 {
    67 $results = $results->$type($table, $join);
    68 }
    69 }
    70 }

    which defines the table property?

  • Stefdv
    17/12/2012 10:01am (2 years ago)

    Hello, this module is great, but ...

    Any change somebody can shine a light on the ajax output ?
    I have no idea where to put the

    if($this->is_ajax()){
    $this->renderWith(array('Ajaxtemplate'));
    }

    And what would be the structure of Ajaxtemplate.ss .

  • Micschk
    03/01/2013 10:19am (2 years ago)

    Hi Aram, this module's really awesome! We've just launched a site which uses it quite extensively.

    Just one weird thing, curious to hear if others have noticed; when in dev mode, if I save a record for the firs time (aka create a new item), my browser crashes (Chrome uses 100% CPU). Firefox just presents me with a empty page.

    I can see the form being posted though, and Firefox receiving an ajax response from the server containing the updated form. When in live mode, all seems to be working just fine. Sounds like a js loop (maybe entwine missing a class or so in dev mode?).<

    When I reload the page, the form has actually been saved and I can publish/save draft etc normally. Any ideas?

  • Aram Balakjian
    03/01/2013 12:17pm (2 years ago)

    Hi Micschk, normally this happens when you have a bug in onBeforeWrite or onAfterWrite. Do you have any code in here that could be causing problems or does that happen on a fresh install of the module too?

  • Micschk
    03/01/2013 12:44pm (2 years ago)

    Nothing in onBefore/AfterWrite. I'll have to try the fresh install to see what happens, will post back here. Thanks!

  • Micschk
    06/01/2013 8:56am (2 years ago)

    Hey Aram, made a fresh ss 3.0.3 install, added DOAP: no crashing. Enabled versioning on the DO: crashes.

    It only crashes on initial saving of a NEW item (at which point I only have the 'save' button, not the versioning 'save & publish' etc, which show up AFTER initial save)

    I'll try and debug further, will post back on Github.

  • kBits
    09/01/2013 2:07am (2 years ago)

    Hi this looks like a great module but I am having a little trouble installing it on a server running PHP 5.3.3 and SilverStripe 3.0.3. The installation seems to go smoothly, but afterword when I try to edit or create a new page in the admin it just hangs and I get no editor. After I remove the module, I am back to normal. Any ideas? Thanks!

  • kBits
    09/01/2013 5:33pm (2 years ago)

    Cancel the above comment, my fault I had a typo in TWO of the page types. That will teach me to work without my coffee. The module is installed and working GREAT, thank you for this AWESOME module :0)

  • kBits
    09/01/2013 8:41pm (2 years ago)

    I was wondering if you could comment on how to implement categories, as in the tutorial where you build the product catalog?

  • kBits
    25/01/2013 11:28pm (2 years ago)

    OK i have figured out implementing categories, but it seems that the BreadCrumbs are a little backwards if you view the product when your Product Listing Page is underneath another page....it goes like this:
    ProductCat >> ProductCatParent >> ProductViewPage

    I can't for the life of me figure out what is happening in the BreadCrumbs function, but shouldn't it read:
    ProductCatParent >> ProductCat >> ProductViewPage

    How to fix?

  • Gaudino
    08/02/2013 9:20am (2 years ago)

    Hi, this module is very usefull, thanks:-)

    How can I except "/show/" from URL? I want to do cleaner URL for my clients.

    I think I need to use $url_handlers variable, but I dont know how.

    Thank you for advice.

  • pinkp
    19/05/2013 10:18pm (2 years ago)

    Can I just ask, am I doing something wrong?
    I've downloaded the module from Github link, added it to root folder. Create the 3 files as in the tutorial. Run Dev Build, and then there is nothing different in the CMS?
    Your log in example is for 2.4.. It says for SS3 on Github but I don't get any changes in the CMS?

  • Aram Balakjian
    20/05/2013 4:11pm (2 years ago)

    Hi Pinkp,

    Which branch are you using on Github/which version of SS? I have just updated the master branch to work with SS3.1 and created a branch for 3.0.

    You should be using a Model Admin interface to manage the objects, so you should see an extra menu item down the left hand side, whatever you titled your ModelAdmin.

    Cheers,

    Aram

  • pinkp
    22/05/2013 10:21am (2 years ago)

    Hi Aram, thank so much for the reply.
    I have just looked and re downloaded version 3 from your branch. Added it to a fresh install of SS3.0.5, created the 3 files in MySite/Code. Done my dev/build and see it add tables then nothing in the CMS admin area. :(

  • Aram Balakjian
    22/05/2013 10:37am (2 years ago)

    Hi Pinkp,

    Is there no new model admin section?

    Aram

  • pinkp
    22/05/2013 11:32am (2 years ago)

    no, and I've installed FlexSlider module from GitHub just now and that shows up in the section. thanks

  • Aram Balakjian
    22/05/2013 11:34am (2 years ago)

    ok I'll take a look.

    Thanks for reporting it.

    Aram

  • Aram Balakjian
    22/05/2013 12:02pm (2 years ago)

    Hi Pinkp,

    Using the 3.0 branch of SS and the 3.0 branch of the module, I created the 3 files as above and I get a 'Products' model admin tab in the left menu.

    I'm not sure what the problem is, but I don't seem to be able to reproduce it.

    Aram

  • pinkp
    22/05/2013 12:31pm (2 years ago)

    Hi Aram,

    I have not literally downloaded a fresh copy of SS3.05, fresh copy of the branch 3.0 version of DOAP. Installed the CMS, added the files from the tutorial. DEV/BUILD.

    and nothing.

    Installed using MAMP, had a magic_quotes warning.. nothing else to report.

    What on earth can I be doing wrong!?

  • pinkp
    22/05/2013 12:31pm (2 years ago)

    *now, sorry.

  • pinkp
    22/05/2013 12:35pm (2 years ago)

    OK major embarrassment!!!

    I copied and pasted your page codes with out syntax highlighting... I missed

    <?php

    from the top of each file! sorry if i wasted your time! at least you know there is not a bug with your code! just me!

  • Aram Balakjian
    22/05/2013 12:36pm (2 years ago)

    lol, no worries we've all done it :)

    Glad it's working, enjoy the module!

    Aram

  • pinkp
    31/05/2013 10:04pm (2 years ago)

    Hi Aram, love this module thank you!

    2 questions. I've been trying but failed.

    1. Best way to set the folder name for images,
    This has no effect:

    new UploadField('Photo', 'Photo', Null, Null, Null, 'Uploads/staff-photos/')

    and this gives me an error:
    $fields->addFieldToTab('Root.MemberImages', new UploadField('Image3','Member Image 3'));
    $fields->setFolderName('photos');

    [User Error] Uncaught Exception: Object->__call(): the method 'setfoldername' does not exist on 'FieldList'


    2. Please point me in the right direction to create a front end filter / sort / search. I've seen lots of talk and snippets but not sure which one to use as I've not done it before. I want to have a drop down list or radio buttons etc. To be able to filter the results by the front end user.

    many thanks

  • pinkp
    01/06/2013 8:52am (2 years ago)

    Fixed my image folder issue: should included $uploadField =

    $fields->addFieldToTab('Root.MemberImages', $uploadField = new uploadField('Image4','Member Image 4'));
    $uploadField->setFolderName('member-photos');

  • Carsten
    01/06/2013 10:30am (2 years ago)

    Hi Aram,

    is there a way to make "DataObject as Pages" compatible with the subsite module? What i want to do is to give each subsite its own news.

    Many thanks for your help and for the module.

  • markuse
    25/10/2013 11:08pm (1 year ago)

    I used this great module so far, the last time with Silverstripe v. 3.0.5 or so. Now I get crazy with Silverstripe v.3.1.1 ....it's not running. Or am I wrong? Anybody an idea what's the problem?
    best
    markus

  • Aram Balakjian
    28/10/2013 12:03pm (1 year ago)

    Hi Markus,

    I have just created a 3.1 branch for use with SS 3.1.x, so make sure you are using that.

    Cheers,

    Aram

  • markuse
    28/10/2013 3:33pm (1 year ago)

    ooops - I ignored the github link
    Thank Aram!

  • Jonas
    06/11/2013 4:05pm (1 year ago)

    Question:
    How can I have more than one productlistingpage for a product?
    ex. productlistingpageone.php/ss and productlistingpagetwo.php/ss

    I want the possibility of listing the products, in the frontend, in 2 different ways, e.g. one template with thumbnails and one template as a list.

    would it be here:
    static $listing_class = 'ProductListingPage';

    Any help would be appreciated.
    Thanks

  • ChristopherW
    01/05/2014 6:41am (8 months ago)

    Hi Aram,

    I'm really looking forward to using this module for several projects, and I can't seem to get it to work. I started with a fresh install of SS 3.1.4 and the module. I copied & pasted all of your examples and can add products, but can't get them to display.

    For some reason, it's using the Page.ss instead of the ProductListingPage.ss. The only way I can see the products is to list them as children and then they'll show up in the sidebar navigation but won't link to the ProductListingPage_show.ss page. Again, defaulting to the Page.ss layout. The URL shows up as http://test.local/products/show/oranges

    Any ideas?

    Thanks!

    Christopher

  • novalix
    07/05/2014 11:34am (8 months ago)

    Hi Aram,

    thanks a lot for your work and the detailed documentation.

    I am currently prototyping a new website project and therefor gave the DOAP-Module a shot. I 'm using the 3.1-branch.

    I have created two different instances of DOAP-ListingPages per copy-pasting the code in this tutorial. It worked but had one major flaw: The data objects of the second instance only showed up under the first listing page.
    Reading the README.md of the module I followed the hint and redefined

    $listing_class = 'MyListingPage'

    to

    $listing_page_class = 'MyListingPage'

    Now everything works as expected.

    Next step: Make it translatable :)

    Groetjes, niels

Post a comment ...

You cannot post comments until you have logged in. Login Here.

Advertisement

Site of the Month

Find SSbits on

Top Contributers

Rank Avatar Name
1 article image Aram Balakjian
2 article image Daniel Hensby
3 article image Marcus Dalgren
4 article image Hamish Campbell
5 article image Ty Barho
6 article image Martijn van Nieuwenhoven
7 article image Darren-Lee
8 article image Roman Schmid
9 article image Matt Clegg
10 article image dalesaurus

View full leaderboard


Advertisement