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

Proposal to allow some static pages to be "wide" #717

Closed
CharliePoole opened this issue Apr 4, 2024 · 9 comments
Closed

Proposal to allow some static pages to be "wide" #717

CharliePoole opened this issue Apr 4, 2024 · 9 comments

Comments

@CharliePoole
Copy link

By "wide" I mean joining the two columns into one wider column.

I have modified HTMLy locally to do this for all static pages and it works technically, but it doesn't suit me because I only want certain limited pages to be wide. Obviously, I could do this by creating a page-specific layout, but I think a page setting of
wide = true/false might be cleaner.

Would you accept a PR to do this? It would be a nice way for me to get started contributing. If it is out of scope for HTMLy and you prefer all non-custom layouts to be 2-column, then I'll use a custom layout file where I need it.

@danpros
Copy link
Owner

danpros commented Apr 5, 2024

For this purposes it better to use the custom config features actually (admin/config/custom). The custom config still persist even we update the htmly.

Edit: and for specific purposes eg, want a custom functions (for subscriptions etc.) use the theme functions.php. Try to create functions.php file inside the theme and write our custom functions and call it in template.

@CharliePoole
Copy link
Author

CharliePoole commented Apr 6, 2024

Hi Dan... Are you sure you mean to use custom config for #717 rather than #716?

For #717, the config file would need to have a table of all pages requiring the special property, so it may be better to store the property with the page itself, at the time the page is created. Can the special comments at the start of each page be used for that purpose... i.e. <!--wide--> or <!--layout=wide--> or something similar? Can you point me to the part of the code where these comments are inserted?

@danpros
Copy link
Owner

danpros commented Apr 6, 2024

The simplest is adding <!--wide--> directly to the content actually. Please create functions.php inside your theme, create custom function, eg.:

<?php

function is_wide ($string) 
{
    $wide = explode('<!--wide-->', $string); 
    if (isset($wide['1'])) {
        return true;
    } else {
        return false;
    }
}

In your static template file you can call the functions:

    <?php if (is_wide($p->body)):?>
    <div class="entry-content this-is-wide">
        <?php echo $p->body; ?>
    </div>
    <?php endif;?>

    <?php if (!is_wide($p->body)):?>
    <div class="entry-content this-not-wide">
        <?php echo $p->body; ?>
    </div>
    <?php endif;?>

That's just an idea, you can improve it to meet what you need.

Edit: or use if else so we only call the function once per page load.

@CharliePoole
Copy link
Author

Thanks. I'll play with this for a bit on my site and do a PR when it's ready.

@danpros
Copy link
Owner

danpros commented Apr 6, 2024

Well no need to add it to the core actually, a better docs is sufficient. With functions.php for theme is enough to allow similar mod.

@CharliePoole
Copy link
Author

Aren't the admin screens part of the core?

@danpros
Copy link
Owner

danpros commented Apr 6, 2024

Is this theme specific setting? I mean existing theme will change also? if not than there are around 18 themes need to be updated (css, html etc.).

We should not add certain settings to the config page (not the custom one) if those settings only affect specific theme. Example Cleanblog theme or Casper theme (dark setting), the setting for those theme not added to the core settings.

Edit: We need to keep the main settings as simple as possible, and use custom settings or functions.php for the rest.

@CharliePoole
Copy link
Author

Ah! I understand now. I thought this could be a new standard setting, supported by the Admin code. But of course, it can't be unless every theme supports it. In that case, I'll keep all the code inside my theme and you can close this.

BTW, this year is my 50th year working in software development, but I haven't used PHP since about 2005. So thanks for helping me get on track.

@danpros
Copy link
Owner

danpros commented Apr 6, 2024

Glad you agree too. Yes we should be as simple as possible with this.

@CharliePoole 50 years and still being active in your field is an achievement in itself, kudos for that. As long as we understand a little about PHP, HTMLy can be said pretty flexible. You're welcome 😃

@danpros danpros closed this as completed Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants