Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

option to turn off ifauthex <p> tags #15

Open
listerr opened this issue Feb 20, 2023 · 4 comments
Open

option to turn off ifauthex <p> tags #15

listerr opened this issue Feb 20, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@listerr
Copy link

listerr commented Feb 20, 2023

Hello,

Really like ifauthex - it has allowed me to do what I need and build some navigation etc. based on groups.

I would like to use it to show or hide items in a top slot navigation menu (bootstrap/combostrap template), but
ifauthex seems to wrap output in <p> </p> tags, which breaks the layout of the top navigation bar.

Is it possible to have an option to suppress this?

Thanks.!

@5p4k
Copy link
Member

5p4k commented Feb 20, 2023

Hi! In fact that depends on the PType of the plugin.
When I first released it I did not consider applications in which one might want to use the plugin "inline", so to say, but it is definitely possible to switch to block or normal.

I wonder whether someone relies actively on the fact that it creates a paragraph every time. I would imagine this is not the case, but I will experiment with the block mode.

@5p4k 5p4k added the enhancement New feature or request label Feb 20, 2023
@listerr
Copy link
Author

listerr commented Feb 21, 2023

Thanks for the update.

Changing a default behaviour is maybe going to do the wrong thing for some people, i.e. if someone has a bunch of ifauthex statements in a page and you were relying on the <p> tags happens to space them out nicely, then you upgrade the plugin and now the layout changes with all the ifauth blocks crashing into each other.

So, probably stuck with it as the default for the immediate future. Since a lot of dokuwikis also support things like markdown / alternative markup, possibly removing the

tags wouldn't end well if ifauth is embedded in markdown, for example.

If there is a config option or parameter to change the behaviour to normal or block, that would be useful. I don't know enough about the DW plugin architecture to know which would be better e.g. if there is a significant performance hit if you have to access the config every time ifauth is called., or if it would be better to have it as a parameter if you want anything other than the default: <ifauth @group |normal> or some such.

@5p4k
Copy link
Member

5p4k commented Feb 21, 2023

If there is a config option or parameter to change the behaviour to normal or block, that would be useful.

Unfortunately I do not think it's possible. I'm not a DW expert, but I believe that the ptype of the plugin is assumed to be constant, based on the fact that there is no indication of when it is queried. It looks like we would need to have two different syntax plugin implementations for that.

Changing a default behaviour is maybe going to do the wrong thing for some people

On the other hand, I'd prefer to have both inline- and block-based behavior rather than not, and to have one tag and one syntax to support rather than two (see above). I need to test how the block mode behaves, if it really does enable both options and the only change that needs to be done for re-enabling paragraphs is adding a blank line at the beginning.

So, probably stuck with it as the default for the immediate future.

In the very immediate future, yes, mainly because I will be accumulating some more changes before doing a release. However, if that is the behavior you seek, why not installing a modified version of the plugin? It's (theoretically) a single-line change. If you are interested I can give you more details on how to do that.

@listerr
Copy link
Author

listerr commented Feb 28, 2023

Thanks for the response. I appreciate it.

AIUI, it's line 70:

    function getPType()
    {
        return 'stack';
    }

Change to return 'block';

So - DW calls that function to get the PType.

Looks like it's possible to have plugins with multiple components:

https://www.dokuwiki.org/devel:plugin_file_structure

Maybe the answer is to do something like:

<dokuwiki>/lib/plugins/ifauthex/syntax/ifauthexp.php        Class: -> syntax_plugin_ifauthex_ifauthexp
<dokuwiki>/lib/plugins/ifauthex/syntax/ifauthexblock.php    Class: -> syntax_plugin_ifauthex_ifauthexblock

etc. So that it can have more than one syntax tag and reuse the common code between the two.

I will experiment if I get time. (Though my php foo is quite basic!.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants