Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#265 2015-12-10 22:24:13
Re: smd_bio : store additional biographical info about your users
Bloke wrote #297053:
Because we didn’t have “real” user accounts for everyone. If everyone has a physical login to Txp, you can use the usual
example.org/author/Destry+Wion
links, and bio pages work out of the box. It’s only because the endpoint was fake that we had to tell Txp not to throw a 404 via gbp_pl.
Excellent.
Offhand, I don’t know, but suspect it’s a lot of work. I’d rather put the energy into revamping Txp’s core URL behaviour than retrofitting one plugin to do it.
Indeed. And it seems no need on my account anyway as it’s all real user accounts in CSF.
Thanks.
Offline
#266 2015-12-11 15:17:43
Re: smd_bio : store additional biographical info about your users
Well, I thought I knew what you were talking about, and figured you meant domain/people/destry-wion
, which is what the URL’s are supposed to be, but maybe I misunderstood.
If you go here, you see various people. If you click on one of their profiles, you get a 404. That has just started happening after I removed gbp_pl.
As I look at the form (now flattened out via rah_flat), I’m not exactly sure 1) where the URL paths you speak of should go, and 2) whether or not smd_if is needed now that gbp_pl has been removed from the equation, but smd_if currently adds an if/else conditional in the form, so the who thing might need a little refactoring to simplify, but I don’t know for sure. I also don’t quite understand those URL path structures you indicate, that’s new to me.
Here’s the form code, can you (or anyone) suggest where I might make some changes?
<txp:smd_if field="pretext:permlink_regex_member, pretext:permlink_regex_member" operator="defined, not" value=",rss">
<txp:hide>** INDIVIDUAL CONTRIBUTOR **</txp:hide>
<txp:smd_bio_author author="SMD_PRIVS:1:2:3:4:5:6">
<txp:hide>
Accounts w/ no rights (SMD_PRIVS:0) not included, so don't output.</txp:hide>
<txp:smd_bio_info>
<txp:smd_if_bio field="url_title" value="{smd_if_permlink_regex_member}" case_sensitive="0">
<article class="principle profile grid" itemscope itemtype="http://schema.org/Person">
<h1 itemprop="name">{smd_bio_RealName}</h1>
<section itemprop="description" class="c10 m">
<txp:smd_wrap transform="textile">
<txp:smd_bio_data fields="bio" />
</txp:smd_wrap>
<txp:smd_wrap labeltag="h2" label='CSF Articles'>
<txp:smd_bio_articles wraptag="ul" break="li" author="{smd_bio_name}" section="articles"><txp:permlink><txp:title /></txp:permlink></txp:smd_bio_articles>
</txp:smd_wrap>
</section>
<figure class="biofigure c6">
<txp:smd_if_bio fields="author_photo">
<txp:image width="0" height="0" id='<txp:smd_bio_data fields="author_photo" />' />
<txp:else />
<txp:image name="nohead.png" width="0" height="0" />
</txp:smd_if_bio>
<figcaption class="headcap">
<txp:smd_if_bio fields="caption">
<txp:smd_bio_data fields="caption" />
</txp:smd_if_bio>
<txp:smd_wrap_all wraptag="ul" class="biocaptionlinks">
<txp:smd_wrap wraptag="li" transform="link|Website">
<txp:smd_bio_data fields="website" />
</txp:smd_wrap>
<txp:smd_if_bio fields="twitter">
<txp:smd_if fields="{smd_bio_twitter}" operator="begins" value="http">
<txp:smd_wrap wraptag="li"><a href="<txp:smd_bio_data fields="twitter" />">Twitter</a></txp:smd_wrap>
<txp:else />
<txp:smd_wrap wraptag="li" transform="replace||@"><a href="http://twitter.com/<txp:smd_bio_data fields="twitter" />">Twitter</a></txp:smd_wrap>
</txp:smd_if>
</txp:smd_if_bio>
<txp:smd_wrap wraptag="li" transform="link|Google+">
<txp:smd_bio_data fields="gplus" />
</txp:smd_wrap>
</txp:smd_wrap_all>
</figcaption>
</figure>
</article>
<txp:variable name="bio_found" value="1" />
</txp:smd_if_bio>
</txp:smd_bio_info>
</txp:smd_bio_author>
<txp:hide> ** CHECK IF A PERSON MATCHED ** </txp:hide>
<txp:if_variable name="bio_found" value="1">
<txp:else />
<h1>Seems to be a problem</h1>
<p>Can't seem to pull up that profile. Let us know about it.</p>
</txp:if_variable>
<txp:else />
<txp:hide> THIS IS WHAT YOU SEE IF YOU HIT THE /people LANDING PAGE FIRST </txp:hide>
<h1>People power</h1>
<p>Are you missing here? <a href="<txp:site_url />docs/article-contributions">Get yourself added!</a></p>
<txp:smd_bio_author author="SMD_PRIVS:1:2:3:4:5:6" sort="RealName asc" wraptag="ul" class="grid people">
<txp:smd_bio_info fields="url_title, RealName, author_photo">
<li class="c33 m">
<a href="<txp:site_url /><txp:section name="people" />/{smd_bio_url_title}">
<span class="people-photo"><img src="/images/{smd_bio_author_photo}.jpg" alt="{smd_bio_RealName}" /></span>
<span class="people-name">{smd_bio_RealName}</span>
</a>
</li>
</txp:smd_bio_info>
</txp:smd_bio_author>
</txp:smd_if>
Offline
#267 2015-12-11 15:23:45
Re: smd_bio : store additional biographical info about your users
Oh, btw, these files are all on Github too, which might be easier for you.
Offline
#268 2015-12-11 21:22:46
Re: smd_bio : store additional biographical info about your users
Destry wrote #297059:
Well, I thought I knew what you were talking about, and figured you meant
domain/people/destry-wion
, which is what the URL’s are supposed to be, but maybe I misunderstood.
If you’re doing that, you need a real, physical Section called people
and articles for each person, otherwise you’ll get 404s. But if you change <txp:section name="people" />
to read just author
and then pass in the real name of the users to build up the URL, then it’ll work. Txp understands the /author/Real+Name
URL pattern by default as a special pattern. So this should work:
<a href="<txp:site_url />author/{smd_bio_realname}"> ... </a>
btw, the smd_if at the top is just to extract a field from gbp_pl, so without the plugin you won’t need the smd_if call.
But the above uses an ‘author’ URL pattern. If you don’t like that and prefer the ‘people’ pattern, there is another way to approach this using some trickery.
Since you know that any author link is going to result in a 404, you can actually trap that situation and exploit it. To do so, you’ll first need to change your author links (at the bottom of people.misc.txp
) to be their real login names instead of the smd_bio_url_title
:
<a href="<txp:site_url /><txp:section name="people" />/<txp:smd_bio_data field="name" />"> ... </a>
OK, so that will render your anchors as domain/people/login
. What you do next is create a new Txp Page called error_404
. This will be rendered whenever anyone hits a non-existent site link. In that Page template you do some smd_if jiggery pokery to detect if the URL contains /people
and act accordingly:
<txp:smd_if field="svrvar:REQUEST_URI" operator="contains" value="/people/">
<txp:smd_bio_author author='<txp:smd_wrap_all transform="split|/||last">{smd_if_REQUEST_URI}</txp:smd_wrap_all>'>
<txp:smd_bio_info
fields="name, RealName, phone, website" />
</txp:smd_bio_author>
<txp:else />
I'm a regular 404: write error template code here.
</txp:smd_if>
So all that does is check if the URL is a bio link (/people/
), uses smd_wrap to split the URL at slash, takes the last part (the login name) and plugs it into the author
attribute of the <txp:smd_bio_author>
tag. Once that’s done, in the smd_bio_author container you’re free to output whatever you like: I’ve just used <txp:smd_bio_info>
in the example to pull out some random bio fields. What you probably want to do is move most of the bio field display stuff out of the top of your current people.txp.misc
Form and stick it there. Decorate the error_404
template with whatever other markup you like (doctype, head, body, divs, whatever).
The top of your people.misc.txp
Form is pretty much redundant at this point as it’ll never be called so that Form can start with:
<h1>People power</h1>
as it’ll only ever be hit to render the list of mugshots.
I’ve tested this approach on my server and it works fine, so give it a go, but if you get hopelessly lost due to my pants instructions then holler again letting me know how far you’ve got and we’ll go from there.
EDIT: one thing to be aware of is that Txp will probably still throw a 404 header so I don’t know what this does to indexing/spidering algorithms in search engines.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#269 2015-12-12 03:50:44
Re: smd_bio : store additional biographical info about your users
Bloke wrote #297063:
If you’re doing that, you need a real, physical Section called
people
and articles for each person, otherwise you’ll get 404s. But if you change<txp:section name="people" />
to read justauthor
and then pass in the real name of the users to build up the URL, then it’ll work. Txp understands the/author/Real+Name
URL pattern by default as a special pattern. So this should work:
There actually is another way. I did a bit of hacking on my mkp_url_parameters plugin and came up with:
if (class_exists('Textpattern_Tag_Registry')) {
Txp::get('Textpattern_Tag_Registry')
->register('mkp_url_person')
;
}
function mkp_url_person()
{
global $variable;
$parts = explode('/', preg_replace("|^https?://[^/]+|i", "", serverSet('REQUEST_URI')), 2);
if ('person' == $parts[1]) {
// person will be true and the variable will be set to the biographical url
$variable['person'] = $parts[2];
} else {
// person will be false and the variable will be set to null
$variable['person'] = null;
}
return null;
}
You then insert something like this at the top of your error_default page (or error_404 if you have one):
<txp:mkp_url_person />
<txp:if_variable name="person">
{custom bio code}
<txp:else />
{regular error page code}
</txp:if_variable>
The 404 error still happens but the person browsing the site gets the content they were looking for. I had been thinking about a way to do AMP in Textpattern and that gave me the idea.
Offline
#270 2015-12-12 09:38:06
Re: smd_bio : store additional biographical info about your users
Bloke wrote #297063:
But if you change
<txp:section name="people" />
to read justauthor
and then pass in the real name of the users to build up the URL, then it’ll work.
Okay.
Just a thought… what if we did it like that and then used mod_rewrite in .htaccess to mask the actual URLs to the original /people pattern?
I’ve no clue what the rewrite rules might be. Any experts in that area?
Barring that, I guess we’d just have to go with /author URLs and then do 301 redirects, yeah? That would be fine with me too.
Offline
#271 2016-06-22 15:33:21
Re: smd_bio : store additional biographical info about your users
- Txp 4.6 beta
- mysql 5.7.13
- php 7.0.7
Tag error: <txp:smd_bio_info fields="url_title, RealName"> -> Textpattern Notice: unregistered_tag while parsing form excerpt-guts on page articles
textpattern/lib/txplib_publish.php:518 trigger_error()
textpattern/lib/txplib_publish.php:463 processTags()
textpattern/lib/txplib_misc.php:4330 parse()
textpattern/publish/taghandlers.php:487 parse_form()
output_form()
textpattern/vendors/Textpattern/Tag/Registry.php:83 call_user_func()
textpattern/lib/txplib_publish.php:514 Textpattern\Tag\Registry->process()
textpattern/lib/txplib_publish.php:463 processTags()
textpattern/lib/txplib_misc.php:4330 parse()
textpattern/publish.php:1003 parse_form()
Offline
#272 2016-06-22 17:38:02
Re: smd_bio : store additional biographical info about your users
Bloke,
I’m revisiting our conversation that started here about gbp_permanent_links role in the CSF /people section to make …/people/first-last links. I’ve decided to refactor that to simply go with the native format of ../author/First+Last in order to drop using gbp_pl and smd_if (only used in relation to that one build).
What I’ve done so far is:
- turn off gbp_permanent_links and smd_if plugins
- removed all instances of smd_if tags use
- remove instances of
url_title
from all instances of<txp:smd_bio_info fields="">
(e.g.<txp:smd_bio_info fields="url_title, RealName, author_photo">
) - replace all instances of
<a href="<txp:site_url /><txp:section name="people" />/{smd_bio_url_title}">
with<a href="<txp:site_url />author/{smd_bio_RealName}">
, per you’re suggestion. (Though I think it was supposed to be “RealName”, not “realname”?)
I’m sure I’m missing something in code somewhere. Evidently I am because it’s not working.
For one thing, I need to drop the former /people section in Sections panel, but do I need to change it to an /author section instead in order to catch the author
part of the URLs?
Currently I can’t go to any profile link using pattern ../author/First+Last. It defaults me to the site homepage with this error at top:
Tag error: <txp:smd_bio_info fields="RealName"> -> Textpattern Notice: unregistered_tag while parsing form excerpt-guts on page default
textpattern/lib/txplib_publish.php:518 trigger_error()
textpattern/lib/txplib_publish.php:463 processTags()
textpattern/lib/txplib_misc.php:4330 parse()
textpattern/publish/taghandlers.php:487 parse_form()
output_form()
textpattern/vendors/Textpattern/Tag/Registry.php:83 call_user_func()
textpattern/lib/txplib_publish.php:514 Textpattern\Tag\Registry->process()
textpattern/lib/txplib_publish.php:463 processTags()
textpattern/lib/txplib_misc.php:4330 parse()
textpattern/publish.php:1003 parse_form()
I know you're busy with 4.6 beta detail, so standing by.
Offline
#273 2016-06-23 00:42:32
Re: smd_bio : store additional biographical info about your users
Tried to create a new bio field. Couldn’t do it, exactly. Got this error…
User_Error "Incorrect integer value: '' for column 'colsize' at row 1"
in /Users/me/Sites/csf/textpattern/lib/txplib_db.php at line 405.
adminErrorHandler()
textpattern/lib/txplib_db.php:405 trigger_error()
textpattern/lib/txplib_db.php:479 safe_query()
textpattern/lib/txplib_misc.php(1783) : eval()'d code:450 safe_insert()
textpattern/lib/txplib_misc.php(1783) : eval()'d code:101 smd_bio_meta_add()
textpattern/lib/txplib_misc.php:1896 smd_bio_dispatcher()
textpattern/index.php:214 callback_event()
Txp’s little red error popup thought maybe I was trying to use a “name” that was already in use, but that wasn’t true.
I looked in the database table and a record was added in the ‘Structure’ but no equivalent record displays in the Bio config panel.
Also, when I hit the ‘Save’ button to create the new field, all the text in the Bio config panel doubled in size. Something goofy there with the admin styling, I think.
I could delete an old bio field without problems, however.
Offline
#274 2016-06-23 09:28:01
Re: smd_bio : store additional biographical info about your users
Destry wrote #299944:
Tried to create a new bio field. Couldn’t do it
User_Error "Incorrect integer value: '' for column 'colsize' at row 1"...
Rats, I get the same. I’ll need to look at this pronto. Watch this space.
In the meantime don’t worry about the ‘unregistered tag’ warnings. For now, you can fix those by finding the block right at the top of the code where everything is registered and swapping it for this bigger block:
if (txpinterface === 'admin') {
add_privs('smd_bio', '1');
register_tab('extensions', 'smd_bio', gTxt('smd_bio_admin_tab'));
register_callback('smd_bio_dispatcher', 'smd_bio');
register_callback('smd_bio_fields', 'author_ui', 'extend_detail_form');
register_callback('smd_bio_admin_js', 'admin_side', 'head_end');
// Note these are all pre Txp's involvement
register_callback('smd_bio_save', 'admin', 'author_save', 1);
register_callback('smd_bio_save', 'admin', 'author_save_new', 1);
register_callback('smd_bio_delete', 'admin', 'admin_multi_edit', 1);
register_callback('smd_bio_welcome', 'plugin_lifecycle.smd_bio');
// Doesn't hurt much to add these if the plugin's not installed.
// Since plugins are loaded in load_order and then alphabetical,
// at this point smd_user_manager doesn't 'exist' (b < u)
register_callback('smd_bio_save', 'smd_um', 'smd_um_save', 1);
register_callback('smd_bio_save', 'smd_um', 'smd_um_save_new', 1);
register_callback('smd_bio_delete', 'smd_um', 'smd_um_multi_edit', 1);
} elseif (txpinterface === 'public') {
if (class_exists('\Textpattern\Tag\Registry')) {
Txp::get('\Textpattern\Tag\Registry')
->register('smd_bio_author')
->register('smd_bio_info')
->register('smd_bio_data')
->register('smd_bio_iterate')
->register('smd_bio_articles')
->register('smd_if_bio')
->register('smd_if_bio_is')
->register('smd_if_bio_first_author')
->register('smd_if_bio_last_author');
}
}
That’ll stop the public side from complaining about existing fields, but won’t fix the admin-side bustage, so you won’t be able to make or edit any fields at the moment, sorry.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#275 2016-06-23 10:29:14
Re: smd_bio : store additional biographical info about your users
Bloke wrote #299947:
Rats, I get the same. I’ll need to look at this pronto. Watch this space.
Cool.
In the meantime don’t worry about the ‘unregistered tag’ warnings. For now, you can fix those by finding the block right at the top of the code where everything is registered and swapping it for this bigger block:
Worked.
Regarding my other side of the battle, I think I kind of understand, maybe. The thing throwing me off is this idea of author profile pages having URLs as ../author/First+Last, because that feature of Txp is something I never knew before, believe it or not. I’ve never seen that documented anywhere. I’m fine using it, that doesn’t bother me. I just don’t understand how it works.
But taking your word for it, what I basically need to do, then, is setup a conditional so that…
- if a user lands on the section, they will see this grid of faces at the new URL, csf.community/authors/ (we’re changing the section name to reflect the specific concept of “authors” instead of “people” in general), and
- if the user clicks on a face, they will see the profile page for said face at URL csf.community/author/First+Last.
Normally I would approach that with something like this on the section’s associated page:
<txp:if_individual_article>
[article form]
<txp:else />
[face grid code]
</txp:if_individual_article>
But with this weird native author URL stuff, I don’t know what is supposed to be inserted in [article form]
in order to make the bio profiles work.
Make sense?
I think if I can just get my noodle around that part of it, I can finish refactoring the whole people/profiles complex, or at least get a ways closer.
Offline
#276 2016-06-23 10:44:14
Re: smd_bio : store additional biographical info about your users
Wait, I might be overthinking it. So the [article form]
would have this in it, right?
<txp:smd_bio_author author="SMD_PRIVS:1:2:3:4:5:6">
<txp:smd_bio_info>
<article class="principle profile grid">
<h1>{smd_bio_RealName}</h1>
<section class="c10 m">
<txp:smd_wrap transform="textile">
<txp:smd_bio_data field="bio" />
</txp:smd_wrap>
<txp:smd_wrap labeltag="h2" label='CSF Articles'>
<txp:smd_bio_articles wraptag="ul" break="li" author="{smd_bio_name}" section="articles"><txp:permlink><txp:title /></txp:permlink></txp:smd_bio_articles>
</txp:smd_wrap>
</section>
<figure class="biofigure c6">
<txp:smd_if_bio field="author_photo">
<txp:image width="0" height="0" id='<txp:smd_bio_data field="author_photo" />' />
<txp:else />
<img src="/assets/img/nohead.png" alt="typewriter">
</txp:smd_if_bio>
<figcaption class="headcap">
<txp:smd_if_bio field="caption">
<txp:smd_bio_data field="caption" />
</txp:smd_if_bio>
<txp:smd_wrap_all wraptag="ul" class="biocaptionlinks">
<txp:smd_wrap wraptag="li" transform="link|Website">
<txp:smd_bio_data field="website" />
</txp:smd_wrap>
<txp:smd_if_bio field="twitter">
<txp:smd_if field="{smd_bio_twitter}" operator="begins" value="http">
<txp:smd_wrap wraptag="li">
<a href="<txp:smd_bio_data field="twitter" />">Twitter</a>
</txp:smd_wrap>
<txp:else />
<txp:smd_wrap wraptag="li" transform="replace||@">
<a href="https://twitter.com/<txp:smd_bio_data field="twitter" />">Twitter</a>
</txp:smd_wrap>
</txp:smd_if>
</txp:smd_if_bio>
<txp:smd_wrap wraptag="li" transform="link|Google+">
<txp:smd_bio_data field="gplus" />
</txp:smd_wrap>
</txp:smd_wrap_all>
</figcaption>
</figure>
</article>
<txp:variable name="bio_found" value="1" />
</txp:smd_bio_info>
</txp:smd_bio_author>
<txp:hide> ** CHECK IF A PERSON'S BIO MATCHED ABOVE ** </txp:hide>
<txp:if_variable name="bio_found" value="1">
<txp:hide>no change</txp:hide>
<txp:else />
<h1>Seems to be a problem</h1>
<p>Can't seem to pull up that profile. Let us know about it.</p>
</txp:if_variable>
Do I don’t need a smd_if_bio
container in there? (Doesn’t seem like I would.)
Offline