API: category label

Posted in: Newspaper
Post count: 388

I’m adding a module via this tutorial: https://forum.tagdiv.com/td_api_moduleadd/

Sounds great, but one question about the category_label parameter. How do I know what the option will be saved as?

That is, when I’m editing the module, I see a line like this:

<?php if (td_util::get_option('tds_category_module_2') == 'yes') { echo $this->get_category(); }?>

Presumably it’s not ‘tds_category_module_2’ for a custom module!

Post count: 388

P.S. In my opinion it’s not 100% clear in that tutorial that the module ID has to end in an integer. I knew it had to be unique, but not that it had to be numerical. I discovered this by encountering a bug where the theme panel does not assign a data-option-value to the new icon, which means it has the appearance of saving the selection but does not really do so, leading to very confusing results!

Post count: 388

…which might just answer my first question

Post count: 1291

Hi,

This id is generated on the spot from the module id – http://screencast.com/t/arArb9HOrpShttp://screencast.com/t/Z03LqTanqgyV

If the module name is td_module_1 the code removes the “td_” in front and ads “tds_category_”.

I’ve added some info on the documentation, sorry for the confusion – http://screencast.com/t/SNISEcQN5d5P

Thank you!

Post count: 388

Thanks! I would still recommend that you say it has to be numerical. I know your instructions give td_module_myname as an example, but when I was trying this out, only integers got converted to data-option-values. For example, with a module to which I gave the id td_module_myname:

http://www.screencast.com/t/tLWQagMtb8

Not sure why this is; it’s just the behaviour I’m seeing. It’s fixed when I make the suffix numerical.

Post count: 1291

Hi,

I’ve changed it, thanks for noticing this. – http://screencast.com/t/kOblkkJYqvi

Have a nice day!

Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic.