For a programmer, thereโs limited scope for change, if you canโt reach the innards of the coding for the product you want to improve, or develop from scratch. There might be configuration files set aside, and though it can be rewarding to adjust these successfully for your purposes, itโs not the same feeling as with Open Source code software available to you, that you can โฆ
- understand โฆ in getting to this, perhaps โฆ
- dynamically seeing in action via a web inspector or IDE mechanism to debug โฆ and thereby know where to intervene, or write from scratch, to โฆ
- recode
โฆ to improve its functionality, or perhaps fix an issue, perhaps caused by a changing environment around that software, or, heaven forbid โฆ a bug.
Supposing an issue to software is caused by a changing environment and your software is not Open Source by nature. Well, there are reinstalls and updates and patches to software going on all the time, and probably it will work, but am sure many programmers out there who are capable of understanding Open Source code would rather debug that code rather that relying on a third party upgrade of software constantly. Well, at least with our WordPress.org Blogโs TwentyTen theme, we get a kick out of having the (codex) PHP source, especially โthe inโ so often, for us, being adjustments to header.php (codex) PHP (as with AlmaLinux WordPress Permalink URL Mapping Tutorial) responsible for the bulk of the look of the HTML and Javascript and even the CSS going towards constructing the blog webpages you are reading now.
Maybe you find it hard to believe a theme dating back to 2010 is not โpast itโ? Itโs debatable we guess, but the Open Source qualities whereby it is open to us to change with our own ideas on top of the excellent start WordPress.org gave us keeps us interested and motivated.
Even so, after all these adjustments, weโre startled that todayโs idea had not occurred to us before today. We were reading this blog on an iPhone via a link from the RJM Programming Landing Page, so scrollwise that way โฆ
- the webpage briefly shows the blog title and heading image and associated menus โฆ before it quickly โฆ
- scrolls down to the heading of the first blog posting
โฆ which all sounds like what somebody reading might want a lot of the time. But then, something immediately in that โabove the foldโ content got us to want to search for a string among all the blog posting content sets. This would be easy on devices larger than this iPhone, as even with an iPad, that search textbox would also be โabove the foldโ within eyesight, in this scenario. But not on an iPhone. That search textbox, for devices of the width of an iPhone, or narrower, place the search textbox, for the WordPress.org blog TwentyTen theme, that is, way down the bottom of the webpage. This is a time consuming scroll operation to get there. So frustrating!
We let this annoyance stew, and wondered whether weโd write some โiPhone device width or lessโ code to help out, when it occurred to us โฆ
- this is not a good idea regarding its specificity โฆ and besides โฆ
- what if the thought occurs to an iPhone reader further down the page โฆ and then we figured โฆ
- what if the thought occurs to any reader further down the page โฆ and then we figured โฆ
- there is room to the right of the caption class=โwp-caption-textโ p element(s) for an emoji
โlinkโ โฆ an a element with no โhrefโ act-u-ally โฆ
<?php
function captionsearchit() {
var ps=document.getElementsByTagName("p");
for (var i=0; i<ps.length; i++) {
if (('' + ps[i].className) == 'wp-caption-text') {
ps[i].innerHTML+=" <a onclick=\"document.getElementById('s').scrollIntoView();\" style=text-decoration:none;cursor:pointer; title=Search>🔍</a>";
}
}
}
?>
โฆ called at document.body โonloadโ event โฆ via โฆ
<?php
<body onload=" setTimeout(captionsearchit, 1000); ... etcetera etcetera etcetera ... ">
?>
โฆ and โฆ - there is the advantage that this solution is so simple โฆ becoming relatively simple after we realized we wanted a mechanism to possibly navigate โBack to readingโ at the search textbox as per โฆ
<?php
function postcaptionsearchit() {
if (document.getElementById('searchform')) {
document.getElementById('searchform').innerHTML+='<span id=spanback style=display:none;><a title="Back to reading ..." id=aback href="#psi0" style=text-decoration:none;cursor:pointer;>🔙</a></span>';
} else {
setTimeout(postcaptionsearchit, 5000);
}
}
function captionsearchit() {
var fone=-1, was_ih='';
var ps=document.getElementsByTagName("p");
for (var i=0; i<ps.length; i++) {
if (('' + ps[i].className) == 'wp-caption-text') {
if (fone < 0) { fone=i; }
was_ih=ps[i].innerHTML;
ps[i].innerHTML+=" <a title='Search ...' data-title='" + was_ih + "' id=psi" + i + " onclick=\"if (document.getElementById('spanback')) { document.getElementById('spanback').style.display='inline-block'; document.getElementById('aback').title='Back to reading ' + this.getAttribute('data-title') + ' ...'; this.title=this.getAttribute('data-title'); document.getElementById('aback').href='#' + this.id; } document.getElementById('s').scrollIntoView();\" style=text-decoration:none;cursor:pointer; title=Search>🔍</a>";
}
}
postcaptionsearchit();
}
?> - there is the advantage that this solution is referencing a codex recognized class name โฆ
- there is the advantage that such captions occur pretty regularly on the webpage โabove the foldโ (hopefully) as well as โbelow the foldโ and โway above the foldโ โฆ
- hopefully adding to a reduction in scrolling frustration for iPhone, and other, readers of this blog, who make use of the search functionality, on a regular basis
Did you know?
Of course, all programmers doing coding over time will have regrets about past practices. In years past we might have expressed setTimeout(captionsearchit, 1000); as captionsearchit(); but am sure a lot of readers see that if weโre chaining a whole lot of document.body โonloadโ event jobs together, more than one can โget on with itโ at a time by using that way of making them โindependentโ expressing it as the scheduled setTimeout(captionsearchit, 1000); timer based Javascript call we have.
Previous relevant AlmaLinux WordPress Permalink URL Mapping Tutorial is shown below.
On this WordPress blog (now on AlmaLinux rather than CentOS) you are reading we have this permalink arrangement whereby URLs to blog postings have within them a representation of the blog posting title. We might be dreaming, but we think the arrangements for this โmapping of URLsโ might have changed with the migration environment change. This would not be surprising. We think the way a โ/โ (forward slash) character that appears in a blog posting title might now โmapโ to a โ-โ (minus) character rather than to nothing that my CentOS dreams never forewarned me of, regarding โฆ tut, tut!
To remedy this, we started fiddling around with good olโ TwentyTen themeโs good olโ headergood olโ.php code where we have many places where we simulate what must go on behind the scenes in WordPress.org based permalink code thinking. And then, we remembered twin good olโ 404twin good olโ.php methodologies for URLs that are not found, and though many will see this as a klunky solution โฆ god knows Luna and Nala find it pretty amusing โฆ we kind of like โฆ
<?php
$uparts=explode("/", $_SERVER['REQUEST_URI']);
if (strpos($_SERVER['REQUEST_URI'], 'apachephp') !== false) {
header('Location: ' . str_replace('--','-',str_replace('apachephp', 'apache-php-', $_SERVER['REQUEST_URI'])));
exit;
}
if (strpos($_SERVER['REQUEST_URI'], 'htmljavascript') !== false) {
header('Location: ' . str_replace('--','-',str_replace('htmljavascript', 'html-javascript-', $_SERVER['REQUEST_URI'])));
exit;
}
if (strpos($_SERVER['REQUEST_URI'], 'phpjavascript') !== false) {
header('Location: ' . str_replace('--','-',str_replace('phpjavascript', 'php-javascript-', $_SERVER['REQUEST_URI'])));
exit;
}
?>
โฆ as the dawn of klunky thinking around here?!
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.