{"id":102,"date":"2010-11-09T18:57:55","date_gmt":"2010-11-09T18:57:55","guid":{"rendered":"http:\/\/www.rangeofvision.com\/?p=102"},"modified":"2021-08-17T09:38:42","modified_gmt":"2021-08-17T09:38:42","slug":"drupal-display-suite","status":"publish","type":"post","link":"https:\/\/www.rangeofvision.com\/index.php\/technology\/cms\/drupal\/drupal-display-suite\/","title":{"rendered":"Drupal Custom pager and Display suite"},"content":{"rendered":"<p>When enabling a Display Suite layout, your custom pagers will disappear.<br \/>\nThis can easily be resolved using a node display custom field.<br \/>\nThe custom field feature is great and allows for very powerful stuff and it lets you get around most issues.<\/p>\n<p>I&#8217;ll provide the solution first and explain later as this can be used to bring in content from other custom modules that add content to the node.<\/p>\n<p><strong>The solution<\/strong><\/p>\n<p>Get the pager details:<br \/>\n1. Go to Home \u203a Site building \u203a Custom pagers (admin\/build\/custom_pagers)<br \/>\n2. Edit the custom pager and make note of the ID its in the URL admin\/build\/custom_pagers\/edit\/1 (pager id = 1)<br \/>\n3. set the pager position to Above the Node body (you will be able to position it using Display Suite wherever you want)<br \/>\n4. Hit the submit to save changes<\/p>\n<p>Add the Node display field<br \/>\n1) Go to Home \u203a Site building \u203a Display suite \u203a Node displays (admin\/build\/ds\/nd\/fields )<br \/>\n2) Expend the \u201cAdd new code field\u201d<br \/>\n3) Giver it a key and title. Make those specific to the pager so something like custom_gallery_pager and custom gallery pager<br \/>\n4) Set the content type the field is relevant to in the \u201cField exclude\u201d section. you must check all types except the one you are interested in (reverse logic)<br \/>\n5) And finely add the \u201cField code\u201d<br \/>\n<code><!--?php print $object--->content['custom_pager_top'][1][\"#value\"]; ?&gt;<\/code><br \/>\nReplace [1] with the relevant pager id you (Get the pager details stage 2) and Save<\/p>\n<p>You an now use your field in your DS layout (:<\/p>\n<p><strong>Analysis<\/strong><\/p>\n<p>Modules that add content to a node would usually add it in the nodeapi to the node content so the first place to look is the node api of the module.<br \/>\nBelow is an extract<br \/>\n<code><br \/>\nfunction custom_pagers_nodeapi(&amp;$node, $op, $teaser, $page) {<br \/>\nswitch ($op) {<br \/>\ncase 'view':<br \/>\n\/\/ We want to make sure we don't try to output when print.module is active.<br \/>\n\/\/ It's a bit of special casing but it doesn't do much harm.<br \/>\nif ($teaser == FALSE &amp;&amp; empty($node-&gt;printing)) {<br \/>\n......................<br \/>\nswitch ($pager-&gt;position) {<br \/>\ncase 'top':<br \/>\n$node-&gt;content['custom_pager_top'][$pager-&gt;pid] = array('#value' =&gt; theme('custom_pager', $nav_array, $node, $pager, 'top'));<br \/>\nbreak;<br \/>\ncase 'bottom':<br \/>\n<\/code><br \/>\nits easy to see how the code adds the content. It does this by creating a new array element according to the $pager-&gt;position.<br \/>\nIn the case of \u2018top\u2019 this is:<br \/>\n<code> $node-&gt;content['custom_pager_top'][$pager-&gt;pid] = array('#value' =&gt; theme('custom_pager', $nav_array, $node, $pager, 'top')); <\/code><br \/>\nso the \u2018#value\u2019 will hold the actual pager giving us (for pager id 1):<br \/>\n<code>$node-&gt;content['custom_pager_top'][1][\"#value\"]  <\/code><br \/>\nwhen using node display fields you must replace the $node variable with $object so the filed code is<br \/>\n<code><!--?php print $object--->content['custom_pager_top'][1][\"#value\"]; ?&gt;<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When enabling a Display Suite layout, your custom pagers will disappear. This can easily be resolved using a node display custom field. The custom field feature is great and allows for very powerful stuff and it lets you get around most issues. I&#8217;ll provide the solution first and explain later as this can be used [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"_links":{"self":[{"href":"https:\/\/www.rangeofvision.com\/index.php\/wp-json\/wp\/v2\/posts\/102"}],"collection":[{"href":"https:\/\/www.rangeofvision.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rangeofvision.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rangeofvision.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rangeofvision.com\/index.php\/wp-json\/wp\/v2\/comments?post=102"}],"version-history":[{"count":4,"href":"https:\/\/www.rangeofvision.com\/index.php\/wp-json\/wp\/v2\/posts\/102\/revisions"}],"predecessor-version":[{"id":120,"href":"https:\/\/www.rangeofvision.com\/index.php\/wp-json\/wp\/v2\/posts\/102\/revisions\/120"}],"wp:attachment":[{"href":"https:\/\/www.rangeofvision.com\/index.php\/wp-json\/wp\/v2\/media?parent=102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangeofvision.com\/index.php\/wp-json\/wp\/v2\/categories?post=102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangeofvision.com\/index.php\/wp-json\/wp\/v2\/tags?post=102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}