Support has been upgraded!
The Support Forum is closed. Not to worry! Providing the top quality support you expect and we're known for will continue! We're not ending support, just changing where you submit requests. This will provide you with the best experience possible.
Premium Support
Have you purchased an addon for Connections such as one of our premium templates or extensions with a valid license and you need help?
Please open a Support Ticket in your user account.
Free Support
Are you using the free Connections plugin? Don't worry, you are still very important to us! We are still providing you with the same high quality support that we're known for.
Please open a new support topic in the WordPress support forums for Connections.
- This topic has 8 replies, 2 voices, and was last updated 9 years, 10 months ago by
Steven Zahm.
-
AuthorPosts
-
07/09/2013 at 8:43 am #264515
Patrick
GuestHi there,
Is there any API reference for creating your own templates?
From looking at different templates there are quite some functions like getBioBlock() that are used to retrieve an entries data.
Is there a listing of them?
Would be great!
Cheers,
Patrick
07/09/2013 at 9:44 am #264516Patrick
GuestFound the answer somewhere else:
It does not yet exist.
Would be cool though!
07/09/2013 at 1:48 pm #264534Steven Zahm
Keymaster@ Patrick
One of my summertime goals is to put up a subsite that has the API docs. For now, all the functions are completely documented in the code. Loos in the
class.output.php
file. Model your template after the included “Names” template. There’s also lot of documentation in theclass.template-api.php
,class.template.php
andclass.template-parts.php
that will be of use.Hope that helps.
07/11/2013 at 10:00 am #264674Patrick
GuestHi Steven,
I tried to use the ‘Names’ template as a basis, but my new template is not recognized.
I kept it identical to the names plugion, however replaced all occurences of ‘Names’ with ‘Test’.
Here my plugion version:
Versions-Informationen
WordPress: 3.5.2
Multisite: No
Connections: 0.7.7.1
Database: 0.1.9The plugin:
directory: ‘test’
filename: ‘test.php’
code:<?php if ( ! class_exists( 'cnTest' ) ) { class cnTest { public static function init() { $atts = array( 'class' => 'CN_Test', 'name' => 'Test', 'type' => 'all', 'version' => '1.0', 'author' => 'Patrick', 'authorURL' => 'example.com', 'description' => 'Description.', 'path' => plugin_dir_path( __FILE__ ), 'parts' => array( 'css' => 'style.css' ) ); cnTemplateFactory::register( $atts ); } } class CN_Test { public function __construct( $template ) { $this->template = $template; $template->part( array( 'tag' => 'card', 'type' => 'action', 'callback' => array( $this, 'card' ) ) ); $template->part( array( 'tag' => 'css', 'type' => 'action', 'callback' => array( $template, 'printCSS' ) ) ); } public function card( $entry ) { $entry->getNameBlock( array( 'link' => TRUE ) ); } } }
07/11/2013 at 11:03 am #264677Steven Zahm
Keymaster@ Patrick
Looks good, at a glance. Couple questions…
Is the
test
direct in this folder?
../wp-content/plugins/connections/templates/
If yes, that’ll be alright just for testing, but you’ll lose the template during a plugin upgrade since WP will delete the Connections folder.
So my suggestion would be to move the
test
folder to theplugins
folder.
Add the plugin header text to the top of thetest.php
file so WP will recognize it as a valid plugin.
Then add the following to the end of thetest.php
file:add_action( 'plugins_loaded', array( 'cnTest', 'init' ), 11 );
Now, when you activate your template under the Plugins admin page, it should show up on the Connections :: Templates admin page.
07/11/2013 at 11:19 am #264678Patrick
GuestActually, it seems the php file is never read.
I added an echo as the first command in both, my test.php file and the names.php file. The printed statement from names.php appears, mine does not.
Is the names.php somehow hardcoded?
Is there any naming convention that should be followd?
I checked the rights and ownership, they are identical for the names and test template:Anyways, making a copy of one of the legacy templates did work. This seems to be workable solution.
Regards,
Patrick
07/11/2013 at 11:40 am #264679Steven Zahm
Keymaster@ Patrick
Just being in the folder does not make it readable, unlike the legacy templates. I’ll be ripping out legay template support in a year or so which is why I recommend following the new way.
Making it a plugin as suggested will make it read by WP and adding the action at the end of the file will register it for use.
07/11/2013 at 12:06 pm #264681Patrick
GuestI have it working, thanks for your support.
But is the main plugin folder the place for a template or should it actually belong somewhere else?
Cheers,
Patrick
07/11/2013 at 12:33 pm #264682Steven Zahm
Keymaster@ Patrick
If you made it a plugin, it would be in the
../wp-content/plugins
folder. If you decided to follow the legacy template format, the foldertest
folder and files should go in the../wp-content/connections_templates/
folder. -
AuthorPosts
You cannot reply to this support topic. Please open your own support topic.