Skip to Content Skip to Menu

Using the new templating method in CB 1.2

15 years 10 months ago #86271 by deni_hanca
Using the new templating method in CB 1.2 was created by deni_hanca
I've only find out just a few moments ago that CB 1.2 comes with a new templating feature. This is new (and great) news for me, so I decided to give it a whack right away.

The idea was to replace the default users list of CB, which uses a table. I was looking to place it into divs, so it can be presented in boxes in an inline style (ala friendster).

And so I do it the fast way: copy the default.php in the default template and place it in my own template. And then make modifications to the _renderBody function in the CBListView_html_default class in that file. Much of my dismay, it actually works!!:laugh:

Question: how do i convert this into a proper template plugin? Or is there somewhere I can refer to regarding this? Thnx!!;)

Wadya Balad Lises Unpad di www.lises-unpad.com

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
15 years 10 months ago #86274 by krileon
Replied by krileon on topic Re:Using the new templating method in CB 1.2
You'll need to copy and edit the XML file as well then package it in a zip file. You will then have a proper plugin template.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

15 years 10 months ago #86329 by deni_hanca
Replied by deni_hanca on topic Re:Using the new templating method in CB 1.2
It turned out that I hacked the default.php in the default template to make it work, but couldn't reproduce it with my own template:dry:

So I restored the default template to it's original. Then make my own version of default.php in my own template, and have it installed.

What I see then is that The frontpage renders the classes from the default template, rather than from my own...? How do I make it render the default.php from my template, instead from the default template? I can't unpublish the default template (error occurs).

I've managed to make my own template without including the php file, but couldn't find an example of how it should be done with the php file included...

Wadya Balad Lises Unpad di www.lises-unpad.com

Please Log in or Create an account to join the conversation.

  • nant
  • nant
  • OFFLINE
  • Posts: 12339
  • Thanks: 1467
  • Karma: 877
15 years 10 months ago #86331 by nant
deni_hanca wrote:

It turned out that I hacked the default.php in the default template to make it work, but couldn't reproduce it with my own template:dry:

So I restored the default template to it's original. Then make my own version of default.php in my own template, and have it installed.

What I see then is that The frontpage renders the classes from the default template, rather than from my own...? How do I make it render the default.php from my template, instead from the default template? I can't unpublish the default template (error occurs).

I've managed to make my own template without including the php file, but couldn't find an example of how it should be done with the php file included...


Did you select your new template from the CB COnfiguration parameter?

Please Log in or Create an account to join the conversation.

  • beat
  • beat
  • ONLINE
  • Posts: 2169
  • Thanks: 463
  • Karma: 352
15 years 10 months ago #86333 by beat
You also need to rename the php file to match the name of your tempate, as well as to rename the few classes inside that file from whateverDEFAULTwhatever to whateverYOURTEMPLATENAMEwhatever.

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in or Create an account to join the conversation.

15 years 10 months ago #86361 by deni_hanca
Replied by deni_hanca on topic Re:Using the new templating method in CB 1.2
This is a screenshot of the members list from my offline test site.

Sometimes one just need to be simple, but behind that simplicity lies great power;) .

You also need to rename the php file to match the name of your tempate, as well as to rename the few classes inside that file from whateverDEFAULTwhatever to whateverYOURTEMPLATENAMEwhatever.

That turned out to be the case for me. Now, just add a little more style, and it'll be ready. This is certainly a better method than hacking the default templates.
It worked:), Thank you Beat, Nant and Krileon :lol:
PS: One thing I noticed though: I only modify one class (CBListView_html). But if I delete the other classes (CBProfileView_html and CBRegisterFormView_html) in mytemplate.php file, it renders blank pages when those classes called. (Because those classes aren't defined in mytemplate.php file, I thought it would render from the default.php instead.. but it didn't). So I just kept it without modifying it:) .

Wadya Balad Lises Unpad di www.lises-unpad.com

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum