{"id":37861,"date":"2010-09-24T11:34:39","date_gmt":"2010-09-24T15:34:39","guid":{"rendered":"http:\/\/www.bu.edu\/tech\/web\/departments\/non-wordpress\/how-to\/creating-custom-template-elements\/"},"modified":"2013-04-11T13:55:28","modified_gmt":"2013-04-11T17:55:28","slug":"custom-template-elements","status":"publish","type":"page","link":"https:\/\/www.bu.edu\/tech\/services\/cccs\/websites\/www\/non-wordpress\/how-to\/coursedescription\/custom-template-elements\/","title":{"rendered":"Creating Custom Template Elements"},"content":{"rendered":"<p>In addition to all the attributes outlined in the <a href=\"https:\/\/www.bu.edu\/tech\/services\/cccs\/websites\/www\/non-wordpress\/how-to\/coursedescription\/course-container-file\/\">Course Container File<\/a> and\u00a0<a href=\"https:\/\/www.bu.edu\/tech\/services\/cccs\/websites\/www\/non-wordpress\/how-to\/coursedescription\/course-template-file\/\">Course Template<\/a> sections, you may also include fields that not included in the available data.<\/p>\n<p>By creating elements that begin with my_, such as my_language or  my_lab, you can generate new attributes for use in the bub_base or  bub_coursetags. These attributes become template variables bearing the  same name as the attributes.<\/p>\n<p>Including a my_ attribute in your container template and a  corresponding my_element in your course template allows you to insert  new information into your output.<\/p>\n<p>If you are adding a my_ attribute to a bub_course tag that returns  multiple courses, you may also include an include_my_ attribute with the  same suffix as the my_ attribute to indicate which courses the  attribute should apply to. If this attribute is omitted, the my_  attribute will be applied to all courses that the bub_course tag  returns; if it&#8217;s included, it will only show up for those courses. The  include_my_ attribute takes a course list formatted in the same way as  the id attribute for the bub_course tag (e.g. &#8220;CASPO101,  CASPO201-CASPO300&#8221;).<\/p>\n<h3>Sample Attribute<\/h3>\n<p>If, for example, you wanted to indicate that certain classes were  counted as lab courses, you could create a variable called my_lab. The  value of my_labwould be set in the container template.<\/p>\n<h3>Container Template<\/h3>\n<p>&lt;bub_base template=&#8221;com.tpl&#8221; output=&#8221;COM-CO&#8221;&gt;<\/p>\n<p>&lt;bub_course id=&#8221;COMCO101&#8243; my_lab=&#8221;This is a lab course.&#8221;&gt;<\/p>\n<p>&lt;bub_course id=&#8221;COMCO102&#8243; my_lab=&#8221;&#8221;&gt;<\/p>\n<p>&lt;bub_course id=&#8221;COMCO301-COMCO999&#8243; my_lab=&#8221;(LAB)&#8221;<\/p>\n<p>include_my_lab=&#8221;COMCO501-COMCO599&#8243;&gt;<\/p>\n<p>Now, you need to create an {!element!} in your course template to  output the contents of my_lab. This element should have the same name as  your new attribute.<\/p>\n<h3>Course Template<\/h3>\n<p>{!college!} {!department!} {!course_num!}<\/p>\n<p>{!title!}. {!my_lab!}<\/p>\n<p>The output on your course description page will render all the precoded attributes and your new attribute, my_lab.<\/p>\n<h3>Resulting Output<\/h3>\n<p>COM CO 101<\/p>\n<p>Way of the Wrld. This is a lab course.<\/p>\n<p>COM CO 201<\/p>\n<p>Introduction to Communication Writing.<\/p>\n<p>COM CO 350<\/p>\n<p>Mass Media in Australia.<\/p>\n<p>COM CO 401<\/p>\n<p>Radio Station Practicum.<\/p>\n<p>COM CO 452<\/p>\n<p>Pol Camp &amp; Comm.<\/p>\n<p>COM CO 500<\/p>\n<p>Directed Study.<\/p>\n<p>COM CO 510<\/p>\n<p>Special Topics. (LAB)<\/p>\n<p>COM CO 523<\/p>\n<p>Comm Structures. (LAB)<\/p>\n<p>COM CO 525<\/p>\n<p>Writing About Society. (LAB)<\/p>\n<p>COM CO 561<\/p>\n<p>Camp&amp;Comm US&amp;Uk. (LAB)<\/p>\n<p>COM CO 570<\/p>\n<p>Special Topics: The Comment Workshop. (LAB)<\/p>\n<p>COM CO 599<\/p>\n<p>COM Internship. (LAB)<\/p>\n<p>COM CO 700<\/p>\n<p>Fin &amp; Strat Mng.<\/p>\n<p>COM CO 704<\/p>\n<p>Teaching Techniques.<\/p>\n<p>COM CO 990<\/p>\n<p>Continuing Stdy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In addition to all the attributes outlined in the Course Container File and\u00a0Course Template sections, you may also include fields that not included in the available data. By creating elements that begin with my_, such as my_language or my_lab, you can generate new attributes for use in the bub_base or bub_coursetags. These attributes become template&#8230;<\/p>\n","protected":false},"author":3321,"featured_media":0,"parent":37730,"menu_order":5,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/37861"}],"collection":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/users\/3321"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/comments?post=37861"}],"version-history":[{"count":7,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/37861\/revisions"}],"predecessor-version":[{"id":64880,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/37861\/revisions\/64880"}],"up":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/37730"}],"wp:attachment":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/media?parent=37861"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}