• Resolved jhaber31

    (@jhaber31)


    I hate to ask a matter of opinion or, conversely, what may be obvious. Here goes. I use WordPress for a blog on my home page. Its design is based on my site’s older html pages, an archive of long, not very blog-like articles. That started almost 30 years ago, so naturally it’s built around a laptop user’s view.

    That means I have never had a version of the design for mobile users. Should I? To my eyes, the type looks way small on a phone, and a single column in such a mobile version but not in the laptop version (where the second column has not content but only a graphic menu) would be better as well. Am I right, or is it not worth the effort?

    Naturally I’d have a learning curve, but in creating the new design and implementing it so that mobile users and only mobile users are sent to it. I’d probably need help with questions. But life is for learning.

    • This topic was modified 4 months ago by jhaber31.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 16 through 17 (of 17 total)
  • Moderator bcworkz

    (@bcworkz)

    I wonder if your phone is caching old CSS so it does not reflect your latest efforts. This can even happen on laptops. Clearing the browser cache should resolve any caching issues. It may not be so obvious (or possible ?) on how to flush a mobile browser cache. Another way to avoid caching issues is to implement “cache busting” techniques. A general internet search will reveal several different techniques. One possibility is, after every CSS change, always alter the URL query string of the stylesheet link tag’s href URL. For example, alter the ver URL parameter which can be done by altering the “version” value in the style.css comment header. How effective this is depends on how the theme enqueues its stylesheet. For some themes you may need to alter the $ver parameter of its wp_enqueue_style() call in functions.php.

    The key to converting a large static .htm site to .php is in being able to use regex to search and replace text in all files in one go. With regex you can capture unique strings in each file (such as title and description) and use the captured text in the replacement text. For example, use each page’s title to define a PHP constant that a single included file can use to output the title tag associated with any webpage’s main file. You can then replace the entire head section with a few define() calls and an include statement.

    The included file could also output any standard body section content such as page header, nav menu, etc. Then if you want to update the nav menu for example, a single edit in one file will impact every webpage that includes that file. A webpage’s main file might start out like this:

    <?php
    define('MY_TITLE', 'Example Title');
    define('MY_DESC', 'Example description');
    define('MY_KEYS', 'example,key,words');
    include head.php;
    ?>
    Main article text starts here. The head.php file handles all HTML before now using the above defined constants

    How to do a regex search and replace varies by O/S. In Linux we can use the find command line utility to locate all .htm files and pipe the results through sed to do the search and replace on each file found. I’ve heard the same can be done in Windows with Notepad++. It’s also possible to accomplish this by writing a bespoke program to do it with your favorite scripting language (that is assuming you have one ?? ).

    Apologies for pitching a concept that’s probably not worth the effort when a CSS solution is feasible, but I think it’s such a cool concept and the idea of writing a script to do the conversion is a good learning to code project in of itself. IMO there’s nothing like a real world project for learning. Probably only worth the effort if the learning experience is as important as getting the PHP conversion done.

    Thread Starter jhaber31

    (@jhaber31)

    Thanks. That really is interesting, and tempting. Meanwhile, I keep playing around, and results are sorta improving. I’ve got it to the point that the sidebar menu in WordPress pages really does vanish in both browsers, phone all the time and laptop after after I size the browser window down. Next, I added the viewport meta tag to other navigation pages, such as search by artist or period in history. Their type size properly improved, too.

    I always had a in my blog just below the page header and before content, saying to “go beyond the blog,” with links to my search by artist, by history, and by what’s new. It occurred to me that, while it has fewer choices than my graphic menu, it could obviate the graphic menu in a pinch. So I added it to the single static html page I’d been using for a test of how to approach the bulk of my site, apart from the home page in WordPress. And then I changed my style sheet for such pages to make that line show only in larger pages (a media statement with display: none but this time with min-width rather than max-width). Sure enough, now just as the graphic menu vanishes, the new line appears.

    I also tried to specify a width for the main column in Word-Press for smaller screens. This hasn’t worked. As I shrink the laptop window or go to the phone, I’m down to that single column (good), but it runs off-screen. Turning the phone sidways fits it just fine, but I’d like to do better. I did clear the cache a lot, as usual. But good guess that this was the problem; it was my instinct, too.

    It occurs to me that, again because I didn’t lay out my WordPress theme, I’m not correctly identifying the class governing my main WordPress content. I guess I’ll just have to keep experimenting.

    Last, if that last style issue can ever be fixed, applying the fix to all my pages could take just two additions to all those pages, with or without php. First, I’d have to add the meta tag for viewpoint to each. Second, I’d have to add the new substitute for a menu. Still daunting, but thanks for the mention of a search opportunity new to me.

    • This reply was modified 3 months, 4 weeks ago by jhaber31.
    • This reply was modified 3 months, 4 weeks ago by jhaber31.
Viewing 2 replies - 16 through 17 (of 17 total)
  • You must be logged in to reply to this topic.