A way to GET view templates available under a block ?

Permalink
Is there a function already existing in concrete to get the list of block view TEMPLATES available under a block. ?

I would like to add a selectbox that would list block view templates at the same time of entering the data.

I find that sometime the extra step of selecting another view template is overkill when they need to add many of the same block.

Thanks

olacom
 
Shotster replied on at Permalink Reply
Shotster
Neat idea!

See method getBlockTypeCustomTemplates() in...

concrete/models/block_types.php

Find an example of usage in...

concrete/elements/block_custom_template.php

-Steve
olacom replied on at Permalink Reply
olacom
Many thanks,

I'll go check it out.

Cheers,
SVijay replied on at Permalink Reply
SVijay
Hi,

try this
$bt = BlockType::getByID($b->getBlockTypeID());
$templates = $bt->getBlockTypeCustomTemplates();
print_r($templates);


For more details visit

http://www.concrete5.org/documentation/developers/blocks/block-type...
olacom replied on at Permalink Reply
olacom
Thanks all,

I think I might have a problem since I'm trying to get the block custom templates from a block that as not yet been added.

I want to display the list of templates available when entering data for the first time in a block.

so the blockObjectId is none existent yet.
Shotster replied on at Permalink Reply
Shotster
> I think I might have a problem since I'm trying to get the
> block custom templates from a block that as not
> yet been added.

Not a problem. Use...

$bt = BlockType::getByHandle('my_block_type_handle');
// ...

Templates are not specific to block instances; they are common to all blocks of a specific type - hence the reason the template list method is in the BlockType class.

-Steve
olacom replied on at Permalink Reply
olacom
Not sure if I explain it correctly.

I'm talking about a PACKAGE/block that I'm creating.

I want to display a SELECTBOX that will list the available templates but with the method I found, I'm able to list it only if the block ID as been created (so thats mean after it's saved and I reedit the block).

BUT when I ADD a new block, it is not created yet until I press save so I have a error.
Shotster replied on at Permalink Reply
Shotster
> I'm talking about a PACKAGE/block
> that I'm creating.

It doesn't matter where your code is; the getByHandle() method should work.

> with the method I found, I'm able to list it only
> if the block ID as been created

The getByHandle() method does not require a block ID. Have you tried it?

If you provide additional information or some code snippets, perhaps we can help further.

-Steve
olacom replied on at Permalink Reply
olacom
ok yes, I see. I'll give it a try brb on this

Thank :)