Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: [solved] Nth year counter from given start
My word, the Mag is quite the smd_ show isn’t it!
A lot of the issues are down to two things:
- PHP 7 is now in use, but plugins use old
mysql_*()calls or functions likesplit()that have been removed from PHP. - A content security policy is forbidding loading a lot of inline scripts, styles and SVG content, so stuff is missing from the admin side. That totally kills smd_macro, though it ought to be possible to design that out in 4.7 with shortcodes so I won’t invest any time in fixing it. Once the CSP is fixed, the plugin will limp along enough for you to copy out the macro definitions into Forms and change any macro calls from things like
<txp:in_issue/>to shortcode counterparts like<txp::in_issue />. Or look in the macro table in the database, but the code might be base64’d, I can’t remember offhand.
I’ve fixed smd_user_manager to use mysqli_*() calls so at least user management limps home. But until the CSP is fixed, it’s hard to diagnose what’s an actual plugin issue and what isn’t.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Offline
Re: [solved] Nth year counter from given start
I’ve set an account up for you, etc. But whether you get the invite depends on whether smd_user_manager behaved itself. I got no notification because the message area uses JS that was blocked by the CSP. If you don’t get it, let me know and I’ll set your password to something and send it to you via PM.
smd_um is using the ‘old’ method of password management unfortunately. Sorely needs an update to bring it inline with the 4.7 methods.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: [solved] Nth year counter from given start
etc wrote #315008:
I see yours (under the name aside your posts), don’t you see mine?
Ah, yes. But sometimes people want to use a different email. I always allow for that at the start. ;)
Offline
Offline
Re: [solved] Nth year counter from given start
Bloke wrote #315007:
My word, the Mag is quite the smd_ show isn’t it!
And a great show it was. I’m sure everything would have been nudged along in regular manner had we stuck with it. ;) It was a fun ride that came to an end only for lack of writers.
If one needs proof, or a situational example, about how important writers are for a website, and especially one oriented around editorial, look no further than TXP. But I got to say, five years on and it still holds it down. It wouldn’t take much for un petit evolu.
Offline
Re: [solved] Nth year counter from given start
Perhaps this could be an agenda item for that pending (virtual) txp-meetup :-)
Jonathan passed over the reigns of Textpattern Tips a couple of weeks ago and txpbuilders now host it (unchanged for the moment but I’ll look at that in due course). The magazine and tips serve similar functions but have different formats. They also overlap with but also augment the docs. Doing the txptips site transfer, and also updating the textpattern.org site to 4.7 recently, where there are also many tips and articles (albeit mostly outdated), made me think that there are number of new things in txp 4.7 that would make good content for magazine articles (e.g. building a theme, making a multi-site installation, working with flat files…) and number of smaller things that would also make good tips (like the new tags and 4.7 tricks like those Oleg has shown us). Maybe we can tie the mag, tips and docs together a bit more…
EDIT: maybe we should split this diverging thread out into a new topic?
TXP Builders – finely-crafted code, design and txp
Offline
Re: [solved] Nth year counter from given start
jakob wrote #315015:
Jonathan passed over the reigns of Textpattern Tips a couple of weeks ago and txpbuilders now host it
Aww… Glad it’s in good hands. Sad to see Mr. Stubbs go, which is essentially what that means. Time wears on us all. :{
EDIT: maybe we should split this diverging thread out into a new topic?
For that sites thinking stuff in relation to a TextMeat, yeah.
As far as the mag concernes my immediate objective for getting an issues system worked out, that discussion can remain here.
Offline
Re: [solved] Nth year counter from given start
Offline
Re: [solved] Nth year counter from given start
I think I’ve found the source of the Rhine. A form called head_context in the mag:
<txp:hide>
==========
Lists of sections that:
* have article content in them (in the order they should appear in lists)
* are aggregates (list-of-other-sections/categories)
* have advertising content (first empty item indicates front page)
==========
</txp:hide>
<txp:variable name="column_sections">from-the-editor, community-spotlight, site-watch, extensionalism, independents-frontline, hope-for-the-future, meaningful-labour</txp:variable>
<txp:variable name="aggregate_sections">columns, exhibit, issues, topics</txp:variable>
<txp:variable name="ad_sections">, advertise, columns, issues, topics, exhibit, <txp:variable name="column_sections" /></txp:variable>
<txp:php>
// query_columns is used in the "in_issue" macro
//TODO: incorporate this into issue_info() too?
global $variable;
$variable['query_columns'] = "'". join("','", do_list($variable['column_sections'])) . "'";
</txp:php>
<txp:hide>
==========
Can use these to test if value="1" in templates
==========
</txp:hide>
<txp:variable name="is_column"><txp:if_section name='<txp:variable name="column_sections" />'>1<txp:else />0</txp:if_section></txp:variable>
<txp:variable name="is_aggregate"><txp:if_section name='<txp:variable name="aggregate_sections" />'>1<txp:else />0</txp:if_section></txp:variable>
<txp:variable name="is_landing"><txp:if_individual_article>0<txp:else />1</txp:if_individual_article></txp:variable>
<txp:variable name="has_ads"><txp:if_section name='<txp:variable name="ad_sections" />'><txp:if_status status="404"><txp:if_section name="">0<txp:else />1</txp:if_section><txp:else />1</txp:if_status><txp:else />0</txp:if_section></txp:variable>
<txp:variable name="has_feed"><txp:php>global $pretext; echo safe_field('in_rss', 'txp_section', "name='".doSlash($pretext['s'])."'");</txp:php></txp:variable>
<txp:hide>
==========
Determine the Mag Issue context. It's either:
a) From the URL (/issues/N that has passed the gbp_permanent_link CF check)
b) From the current individual article's "Issue" custom field
c) From the Issue CF of the most recent past live article in the mag content
==========
</txp:hide>
<txp:variable name="issue" value="0" />
<txp:php>
function issue_info($iss = '0') {
global $variable, $pretext;
static $issue_row;
static $issue_stamp;
if (!isset($issue_row) && !$issue_row) {
$iss_clause = ($iss != '0' && is_numeric($iss)) ? " AND custom_1='".doSlash($iss)."'" : '';
$post_clause = (isset($pretext['month']) && $pretext['month']) ? " AND Posted LIKE '".doSlash($pretext['month'])."%'" : ' AND Posted < NOW()';
$issue_row = safe_row('MAX(custom_1) AS custom_1, MAX(Posted) AS Posted', 'textpattern', "Section IN (" . join(',', quote_list(do_list($variable['column_sections']))) . ")" . $post_clause . " AND Status='4'" . $iss_clause);
$issue_stamp = strtotime($issue_row['Posted']);
}
return array($issue_row, $issue_stamp);
}
</txp:php>
<txp:if_status status="200">
<txp:if_section name="issues">
<txp:php>
global $variable, $pretext;
$date = array(); // Holds the ?month URL param portions
$uri = serverSet('REQUEST_URI');
$qs = serverSet('QUERY_STRING');
$qs = ($qs) ? '?'.$qs : '';
$uri = str_replace($qs, '', $uri);
$uri = do_list($uri, '/');
$pos = array_search('issues', $uri) + 1;
if (isset($uri[$pos])) {
if (is_numeric($uri[$pos])) {
$uri[$pos] = (int) $uri[$pos];
// Anything above 2001 is assumed to be a year. Limits the mag to 2001 issues!
if ($uri[$pos] < 2002) {
$variable['issue'] = $uri[$pos];
} else {
// Year
$date[] = $uri[$pos];
$pos++;
if (isset($uri[$pos]) && is_numeric($uri[$pos])) {
// Month
$date[] = str_pad( (int) $uri[$pos], 2, '0', STR_PAD_LEFT);
$pos++;
if (isset($uri[$pos]) && is_numeric($uri[$pos])) {
// Day
$date[] = str_pad( (int) $uri[$pos], 2, '0', STR_PAD_LEFT);
}
}
// Fake Txp's month filter
$pretext['month'] = join('-', $date);
}
}
} else {
$variable['issue'] = 0;
}
$variable['is_issue_landing'] = ($variable['issue']) ? '1' : '';
</txp:php>
<txp:else />
<txp:if_individual_article>
<txp:if_custom_field name="issue">
<txp:variable name="issue"><txp:custom_field name="issue" /></txp:variable>
</txp:if_custom_field>
</txp:if_individual_article>
</txp:if_section>
</txp:if_status>
<txp:hide>
==========
No issue found: get latest Issue CF from latest article
==========
</txp:hide>
<txp:if_variable name="issue" value="0">
<txp:php>
global $variable;
list($issue_row, $issue_stamp) = issue_info();
$variable['issue'] = $issue_row['custom_1'];
</txp:php>
</txp:if_variable>
<txp:hide>
==========
Create the Month/Year of Issue
==========
</txp:hide>
<txp:php>
global $variable;
list($issue_row, $issue_stamp) = issue_info($variable['issue']); // In case it's not been set up already
$when = ($issue_stamp) ? $issue_stamp : time();
$variable['issue_month'] = date('M', $when);
$variable['issue_year'] = date('Y', $when);
</txp:php>
The php is beyond me, but I’m guessing by looks of keywords, this is where the magic happens for filling things like: <txp:variable name="issue" />, etc.
So my question at this point is just this: If I’m not trying to mimic the past issues links just yet… If all I want right now is the ability to create the mag’s home page list of article in the current issue… What pieces of the puzzle do I need to replicate that in my own project?
I think that would be a good start, combined with the bit from etc at head of this thread for the year count.
Offline
Re: [solved] Nth year counter from given start
A little more clarity on what I’m doing at my end, compared with the Mag.
Columns
I did not originally set out to use columns like the Mag does, but I have sections that could be used that way, and the more I look at it, the more I’m growing on the idea. I like how the columns are explained on a sticky list like that. I could set that up easy enough. My only hesitation is I didn’t want to use .../section/title URLs, I wanted just .../title URLs for simplicity because the site is already sitting at a subdomain. I’ll have to think about that.
Issues
As mentioned, I did not intend to keep historical links for past issues. I was only concerned about having a list of articles for the current issue on the home page, and then letting the archive work by itself for accessing individual articles. Especially as there will not be high turnover at my site, and perhaps not many issues with more than one article. :)
But, again, I’m liking the convenience that these past issue lists provide. So, that’s a possible phase 2 at this point.
Homepage
So if I really keep it simple, as originally intended. I only need three things to happen, all on the homepage:
- The 1st Year — No. n parts in the left side of banner.
- The Issue date (ideally DD Month YYY) in the right side of banner.
- The current issue list of articles at top of the homepage main area.
The first I should be able to setup using etc’s, script for the birthdate and then using <txp:variable name="issue" /> for the issue number.
The second should be similar, I think, using: <txp:variable name="issue_month" /> and <txp:variable name="issue_year" />. I’m not sure about the day part though. The mag doesn’t have that.
The third part I should also be able to setup using the mag’s forms.
I just need some help knowing which parts of the head_context form to pick out to make it all run.
Offline
Re: [solved] Nth year counter from given start
I’ve decided to keep my site as dead simple as possible. It has some notions of being published in ‘issues’, but it’s not a full-fledged magazine like TXP so there’s no need for back issue links and back-issue archives and all that.
An update on my objectives…
As mentioned before, I use a simple sub.domain.tld/title URL pattern. That’s enough to make every link unique and that’s all I want. I’m not trying to reflect a pseudo site structure in my URLs. Homie don’t care anymore.
While I have a number of sections that will never be visible as such to visitors (I simply use them to make convenient article lists by section name type), there are two main views to my site: homepage and ‘stories’ (what I call full articles). Each has its own masthead and main content, quite different in both cases.
The homepage is essentially being modeled like an old Parisian journal. The masthead provides all the journal’s typical details:
- Name of rag
- Editor (moi)
- Year since founded (thank you, etc.)
- Issue number
- Date of issue
- (other static details)
The homepage essentially serves as the site archive too. Think of it as the journal’s index for all published articles to date, organized in broad section/type lists. The main content area is composed of two regions in this order:
- Current Issue (highlight list of articles in latest issue, probably never more than two titles, generally only one)
- Archive (not called that, but what it is, an archive of all published articles)
The items in bold in the above two lists are the parts that concern my interests/needs in this thread for handling ‘issue’ stuff.
The ‘year since’ and ‘issue number’ are handled with this, easy-peasy:
<p class="issue"><txp:evaluate query='ceiling((<txp:posted format="%Y%m%d" /> - 20171223) div 10000)' /><sup>st</sup> Year — № <txp:custom_field name="issue" /></p>
The issue number simply pulls from the latest article’s CF issue value, which will always be the current issue number, right? Right.
The ‘issue date’ is also handled easily, using the latest article’s post date:
<p class="date"><txp:posted /></p>
Since any articles in a given issue will have the same DD/Month/YYYY time (different only by the seconds), this works nicely for my needs.
It works because I’m not keeping track of back-issues and back-issue links. Once the homepage reflects a new issue (by posting one or two new articles in a new date with new issue number) the old issue information is no longer relevant or needed. Poof! What I will do though, is take a screen grab of each new homepage issue, and that will be a personal record of them. I’m not even sure I care about it. I guess it’s the equivalent of a Wayback Machine capture (though I’m not allowing the site in the Wayback; will be requesting they do not archive it, in fact).
If there could be a plugin that does the screenshots automagically when a new article series with higher issue number is published, and saves the grabs to the Files panel too, that would be cool, I guess. But I can do it manually.
So the only thing I need to figure out now to be handled dynamically, is the ‘current issue’ list. It would be intelligent enough to know what articles are in the latest issue and output there titles only (no descriptions). That’s it. But I can’t figure that out from the mag, which is overkill code in this case and too damn complicated for me to figure out. I’ve tried pulling variables and php code out of what seems the relevant places, but nothing works. I get no results, no output.
I think it would be a lot easier to just create what I need for my situation from scratch. But I’m pretty sure this require some modicum of the mag’s PHP wizardry. I just don’t know how to do it. Can anyone help me with this ‘current list’ part? If I get that done. This thread is done too. ;)
Stories
Just to give you the other side of the token…
The masthead here loses all the publishing details except for rag name (logo) and acquires a stories-oriented navigation bar (previous, next, latest, all…). Because most of my articles are quite long, the stories nav bar is repeated just above the footer too. Finish reading a story, jump to the next one. ;)
The main content area is the big enchilada you expect (hed, dek, byline, word count, excerpt, body, endnotes, whatever)
There are no other views in this site, just homepage and stories. All auxiliary things like Contact, Policies, etc which are linked in the footer will go to wion.com (the origin domain), where my work presence will be set up and available at the same time. A double site launch!
Whether that kind of hierarchical data management structure across domain levels is practical, I’m not sure yet, but I like it from the ‘authority’ standpoint, which might serve better in professional situations. It will probably make more sense when can actually experience it. ;)
Offline
Re: [solved] Nth year counter from given start
Destry wrote #315035:
Can anyone help me with this ‘current list’ part?
You can calculate the “shift” years number and store it in a variable:
<txp:variable name="shift" escape="integer">
<txp:php>echo floor((strftime("%Y%m%d") - 20171223)/10000);</txp:php>
</txp:variable>
Then plug it into <txp:article_custom />:
<txp:article_custom time='2017-12-23 +<txp:variable name="shift" />years' />
Offline
Re: [solved] Nth year counter from given start
etc wrote #315036:
You can calculate the “shift” years
Thanks for looking at this, etc. If I understand, your variable is assuming a given issue is a 12 months interval of time?
Unfortunately, the periodicity is irregular. Stories are published when they are ready. That may be 3 months, or it may be 3 years. Sometimes I might decide to publish multiple stories which would influence the time before an new issue was ready as well.
This is what Bloke has under the ‘current issue list’ on the TXP Mag home page:
<txp:smd_featured label='issue_<txp:variable name="issue" />' wraptag="dl">
<txp:variable name="feat_title"><txp:smd_featured_info item="title" /></txp:variable>
<dt><txp:permlink><txp:if_variable name="feat_title" value=""><txp:title /><txp:else /><txp:variable name="feat_title" /></txp:if_variable></txp:permlink></dt>
<dd><txp:smd_featured_info item="description" /></dd>
</txp:smd_featured>
I installed the plugin and tried to mimic it all, but I’m not having luck. There’s more to the obvious eye going on there somewhere, but heck if I can figure it. Sorry.
Offline
Re: [solved] Nth year counter from given start
Just for the record, here’s what I have so far.
Two articles, both published 29 December 2017 (different only by hours/minutes/seconds). Both having CF issue value 1. So I would expect these two articles to appear in the current issue list at this point.
In homepage for the “current issue” list:1
<txp:hide>==========================================================================================
Variable to calculate the “shift” time (years) between issue numbers.
Then called in homepage for current issue articles.
==========================================================================================</txp:hide>
<txp:variable name="shift" escape="integer">
<txp:php>echo floor((strftime("%Y%m%d") - 20171223)/10000);</txp:php>
</txp:variable>
<txp:article_custom time='2017-12-23 +<txp:variable name="shift" />years' form="current_issue_list" />
And in the current_issue_list form:
<dl class="current">
<dt><a href="<txp:permlink />"><txp:title /></a></dt>
<dd><txp:custom_field name="deck" /></dd>
</dl>
I get one article, but not two.
————————————
1. Btw, when I put this variable in my dedicated variables form that outputs at the very top of the DOM (before the html tag) it doesn’t work. But if I put the variable just before where I call it. It works. Why the difference?
Last edited by Destry (2018-11-07 13:38:52)
Offline