Viewing 10 replies - 1 through 10 (of 10 total)
  • Hi Dave, I have a suggestion ??

    I would like to know how to check if a variable is empty.

    For example, if the block content is My name is %%name%%. I want to define a default value for %%name%% when it’s empty.

    [contentblock id=1 name=”John Doe”] -> “My name is John Doe”

    [contentblock id=2] -> “My name is Default Name”

    Plugin Author Dave Liske

    (@delmarliske)

    Hi IvanRF … In thinking this through it almost intantly becomes unwieldly. Where does the default value get declared at? The Settings page makes the most sense. But then the other possibilities present themselves, such as %%address%%, %%city%%, %%email%%, %%standardprice%%, %%exesphonenumber%%, %%requiredmilkfat%%, %%milestonextpineapple%%, and anything else that might be needed. Do we then allow an (almost) unlimited array of defaults, the same as the blocks themselves? Do they also need an import/export? Or did you have something else in mind for the mechanics of it? I’m definitely open to suggestions, this one might be headache-worthy though … ??

    No no, that’s not what I meant. I just want to know how to check if the variable is empty ??

    Then, with code (inside the Content Block) I will add the default value, but for that I need to check if it is empty.

    Plugin Author Dave Liske

    (@delmarliske)

    Ah, gotcha, let me think on that a bit. At the moment it displays “My name is %%name%%” if it’ empty. Your code might be able to test for this somehow, not sure how you’ve written it. If that doesn’t work I’d need to set some sort of flag.

    Just a thought, since you use specific characters like %% to define variables, what if you use something like %%variable||"default value"%%

    Plugin Author Dave Liske

    (@delmarliske)

    I like it, I’ll get to work on it. Thanks.

    Plugin Author Dave Liske

    (@delmarliske)

    IvanRF, we have Defaults working for the next version, please see the working examples at:

    https://micuisine.com/content-block-plugins/2015/11/08/using-variables-within-content-blocks/

    I think the approach showed in the example is wrong. Why would you set a default value in the same shortcode where you can set the actual value?

    For example, [contentblock id=4 default="Monticello Pooh"] will have the same result as [contentblock id=4 name="Monticello Pooh"]. So, why use default there.

    The default value must be set only once where you actually define the variable. That’s why my example was %%variable||"default value"%%.

    Plugin Author Dave Liske

    (@delmarliske)

    Wow, I could not have gotten that more wrong. We’re back to the drawing boards. Good thing I didn’t actually release that … I’m crawling back into my cave for bit …

    Hey Dave. How are you going?
    Any update on this plugin?
    Seems to have been taken down from repository.
    Which version is stable and where can I get it?

    regards Jason

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘New Web Site for GCB Plugin’ is closed to new replies.