<?xml version="1.0"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Page comments</title>
		<link>http://www.ssbits.com/home/</link>
		<atom:link href="http://www.ssbits.com/home/" rel="self" type="application/rss+xml" />
		<description></description>

		
		<item>
			<title></title>
			<link>http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/#PageComment_2417</link>
			<description>Great tutorial, so big thanks. 

sjdeere , I know it's probably been a while since you've looked at this but did you ever solve the issue of the pagination paging through all products instead of just that categorys? </description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/#PageComment_2417</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/#PageComment_1804</link>
			<description>Hello

BAsed on this wonderfull tutorial I have tried to make a site fro gallery.

Everuthing works fine exept for one problem.

I can attched a product to a categorie from the main language site tree bur when a page is translated I can't get it to work. 

Here is the code for my Product.php (I called it Oeuvre)

If anyone has a trick for that greatly apreciated :

&lt;?php

class Oeuvre extends DataObject
{
static $db = array(
'Titre' =&gt; 'Varchar(255)',
'Annee' =&gt; 'Text',
'TechniqueFr' =&gt; 'Text',
'TechniqueEn' =&gt; 'Text',
'Editions' =&gt; 'Text',
'DescriptionFr' =&gt; 'Text',
'DescriptionEn' =&gt; 'Text',
'URLSegment' =&gt; 'Varchar(255)',
'MetaTitle' =&gt; 'Varchar(255)'
);

//Set our defaults
static $defaults = array(
'Title' =&gt; 'New Oeuvre',
'URLSegment' =&gt; 'new-Oeuvre'
);

static $has_many = array(
'Photos' =&gt; 'Photo'
);

//Relate to the Artiste and Exposition pages
static $belongs_many_many = array(
'Artistes' =&gt; 'ArtistePage',
'Expositions' =&gt; 'ExpositionPage'
);

//Fields to show in ModelAdmin table
static $summary_fields = array(
'Titre' =&gt; 'Titre',
'Artistes' =&gt; 'Artiste',
'Thumbnail' =&gt; 'Image'
//'Photos.CMSThumbnail.Tag'=&gt; 'Photo'
);

//Thumbnail to show in ModelAdmin table
function getThumbnail()
{
if($gallery = DataObject::get_one(&quot;Photo&quot;, &quot;OeuvreId = {$this-&gt;ID}&quot;))
return ($img = $gallery-&gt;Attachment()) ? $img-&gt;CroppedImage(150,150) : &quot;no image&quot;;
return &quot;no gallery&quot;;
}
//Add an SQL index for the URLSegment
static $indexes = array(
&quot;URLSegment&quot; =&gt; true
);

//Fields to search in ModelAdmin
static $searchable_fields = array (
'Titre',
'URLSegment',
'Artistes.ID' =&gt; array(
'title' =&gt; 'Artiste'
),
'Expositions.ID' =&gt; array(
'title' =&gt; 'Exposition'
)
);

public function getCMSFields()
{
$f = parent::getCMSFields();
$manager = new FileDataObjectManager(
$this, // Controller
'Photos', // Source name
'Photo', // Source class
'Attachment', // File name on DataObject
array(
'Titre' =&gt; 'Titre',
'Annee' =&gt; 'Année',
'TechniqueFr' =&gt; 'Technique Français',
'TechniqueEn' =&gt; 'Technique English',
'Editions' =&gt; 'Editions',
'DescriptionFr' =&gt; 'Description Français',
'DescriptionEn' =&gt; 'Description English',
'URLSegment' =&gt; 'URL Segment',
'MetaTitle' =&gt; 'Meta Title'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
$manager-&gt;copyOnImport = false;
$f-&gt;addFieldToTab(&quot;Root.Photos&quot;, $manager);
//Artistes
$Artistes = DataObject::get('ArtistePage');
$f-&gt;addFieldToTab(&quot;Root.Artistes&quot;, new CheckboxsetField('Artistes', 'Artistes', $Artistes));

//Exposition
$Expositions = DataObject::get('ExpositionPage');
$f-&gt;addFieldToTab(&quot;Root.Expositions&quot;, new CheckboxsetField('Expositions', 'Expositions', $Expositions));
return $f;
}

//Set URLSegment to be unique on write
function onBeforeWrite()
{
// If there is no URLSegment set, generate one from Title
if((!$this-&gt;URLSegment || $this-&gt;URLSegment == 'new-Oeuvre') &amp;&amp; $this-&gt;Title != 'New Oeuvre')
{
$this-&gt;URLSegment = SiteTree::generateURLSegment($this-&gt;Title);
}
else if($this-&gt;isChanged('URLSegment'))
{
// Make sure the URLSegment is valid for use in a URL
$segment = preg_replace('/[^A-Za-z0-9]+/','-',$this-&gt;URLSegment);
$segment = preg_replace('/-+/','-',$segment);

// If after sanitising there is no URLSegment, give it a reasonable default
if(!$segment) {
$segment = &quot;Oeuvre-$this-&gt;ID&quot;;
}
$this-&gt;URLSegment = $segment;
}

// Ensure that this object has a non-conflicting URLSegment value.
$count = 2;
while($this-&gt;LookForExistingURLSegment($this-&gt;URLSegment))
{
$this-&gt;URLSegment = preg_replace('/-[0-9]+$/', null, $this-&gt;URLSegment) . '-' . $count;
$count++;
}

parent::onBeforeWrite();
}

//Test whether the URLSegment exists already on another Oeuvre
function LookForExistingURLSegment($URLSegment)
{
return (DataObject::get_one('Oeuvre', &quot;URLSegment = '&quot; . $URLSegment .&quot;' AND ID != &quot; . $this-&gt;ID));
}

//Generate the link for this Oeuvre
function Link()
{
//if we are on a Artiste page return that
if(Director::CurrentPage()-&gt;ClassName == 'ArtistePage')
{
$Artiste = Director::CurrentPage();
}
//Otherwise just grab the first Artiste this Oeuvre is in
else
{
$Artiste = $this-&gt;Artistes()-&gt;First();
}
//Check we have a Artiste then return the link
if($Artiste)
{
return $Artiste-&gt;absoluteLink() . 'show/' . $this-&gt;URLSegment;
}
}

}</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/#PageComment_1804</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/#PageComment_1295</link>
			<description>Hi Nick,

Items in model admin don't have a sort order relative to each other, as they are not 'attached' to anything, so there is no way to have drag and drop ordering (as far as I know).

If you wanted to sort them on a particular page, you would need to attach them to that page with a has_many or many_many then sort them there using a DOM.

Aram</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/#PageComment_1295</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/#PageComment_1293</link>
			<description>Hi Aram, is it possible to enable drag &amp; drop sorting in modelAdmin??  I've had a search around but can't seem to find anything on this.....</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/#PageComment_1293</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/#PageComment_1287</link>
			<description>Hi James, have you tried the DataObject as Pages module? it does pagination, searching and versioning right ot of the box! It's here: http://www.ssbits.com/tutorials/2012/dataobject-as-pages-the-module/</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/#PageComment_1287</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/#PageComment_1286</link>
			<description>Hi Aram,

Absolutely great tutorial, you have saved me hours of work. Ive implemented it into a site im working on and added a few bits which are working great. However...im stuck trying to paginate the products and although I know html and css my php is basic, has anybody managed to get around this yet?

James :)</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/#PageComment_1286</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/#PageComment_1267</link>
			<description>Hi Aram, thanks very much for your explanations. I'm using canView() function because the sidebar wouldn't show otherwise. I'm going to use return true for that now. Thanks heaps for your help. Looking forward to your next tutorial. Thanks, S:)</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/#PageComment_1267</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/#PageComment_1262</link>
			<description>sorry, I should have looked a little closer at what you were doing. I'm not entirely sure why you need to do what you are doing, but you can't call canView() on Categories() as that returns a ComponentSet (similar to a DataObjectSet). You could do Categories()-&gt;First()-&gt;canView() but again not sure how that would be doing anything useful, you may as well just return true;

Aram </description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/#PageComment_1262</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/#PageComment_1261</link>
			<description>Hi Aram, 

Thanks very much for your reply! You are right that I need to change $this-&gt;CategoryPages()-&gt;canView to $this-&gt;Categories()-&gt;canView. However another error came up: [User Error] Uncaught Exception: Object-&gt;__call(): the method 'canview' does not exist on 'ComponentSet' Any suggestions on how to fix it? 

I'm building the site on localhost at the moment, thanks very much Aram.

Sam:)</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/#PageComment_1261</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/#PageComment_1257</link>
			<description>Hi Sam,

Do you mean to call $this-&gt;Categories()-&gt;canView? The relationship on Product is Categories, so not sure where CategoryPages() comes from?

Aram </description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-2-using-model-admin-and-url-segments-to-create-a-product-catalogue/#PageComment_1257</guid>
		</item>
		

	</channel>
</rss>