Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#277 2016-06-23 11:08:26

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: smd_bio : store additional biographical info about your users

Nope. Didn’t quite work. I used the following, but while the AUTHORS GRID part works fine, the INDIVIDUAL AUTHOR PROFILE (code above sans the smd_if_bio container) still comes up blank. More accurately, it defaults me to the site homepage.

Of course, this could be due to the bug you’re fixing, so I’ll sit tight until further notice. ;)

<txp:if_individual_article>

  <txp:hide> =========  INDIVIDUAL AUTHOR PROFILE ========== </txp:hide>
  <txp:output_form form="authors" />

<txp:else />

  <txp:hide> ===============  AUTHORS GRID  =========== </txp:hide>
  <h1>Authors hall of fame</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="RealName, author_photo">
      <li class="c33 m">
        <a href="<txp:site_url />author/{smd_bio_RealName}"><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:if_individual_article>

/ the crowd eerily cheers ever louder and fervently… Bloke! Bloke! Bloke! …. /

Offline

#278 2016-06-23 12:09:26

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,453
Website GitHub

Re: smd_bio : store additional biographical info about your users

Destry wrote #299950:

author profile pages having URLs as ../author/First+Last

Firstly, don’t make a section called author as that’ll probably break things. But you probably figured that out already :-)

Secondly, by default, any URLs of the pattern /author/some+name will execute your ‘front page’ (default) Page. So in that template you need:

<txp:if_author>
   // smd_bio tags to show individual bio for
   // given author goes here.
</txp:if_author>

It won’t trigger individual_article context because it’s not an article. But equally — and somewhat annoyingly — it won’t trigger ‘author list’ context if there is no author specified (at least, as far as I know… maybe someone can prove me wrong).

Using /category without a category after it will 404, but /author without an author after it will just do… well, nothing except not trigger the <txp:if_author> conditional.

The upshot is that we’re back to hoop-jumping to hook into something that displays a list of authors. Enter smd_if:

<txp:if_author>
   // "Individual" author context
<txp:else />
   <txp:smd_if field="svrvar:REQUEST_URI, svrvar:REQUEST_URI" operator="ends, ends" value="author, author/" logic="or">
      // Author "list" context.
   </txp:smd_if>
</txp:if_author>

If you stuff the appropriate individual bio / list-of-bios code in those blocks it should work.


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

#279 2016-06-23 13:37:41

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: smd_bio : store additional biographical info about your users

Bloke wrote #299953:

don’t make a section called author

Roger. I had created one called authors, with and ‘s’, to make a distinction. I wanted to try putting the author list, at least, on it’s own “authors” section, which I seem able to do. And when I say “list”, I actually mean this grid of photos and names only.

by default, any URLs of the pattern /author/some+name will execute your ‘front page’ (default) Page.

Okay, that explains that behavior. New (and bizarre) territory for me. And I see this means having to adjust template structure there too in order to negotiate between author and regular homepage content/presentation. That’s more tinkering than I expected, but I’m committed now.

It won’t trigger individual_article context because it’s not an article. But equally — and somewhat annoyingly — it won’t trigger ‘author list’ context if there is no author specified (at least, as far as I know… maybe someone can prove me wrong) … Using /category without a category after it will 404, but /author without an author after it will just do… well, nothing except not trigger the <txp:if_author> conditional.

You’re kind of losing me there. Are you saying I cannot put the author list on it’s own section? I must put it into the if_author conditional on the homepage too? That’s not really ideal because we want a landing page for the grid. From there, when a user clicks a face, it can open the profile in the homepage, that’s fine.

In any case, I tried it both ways. First like you suggested, using:

<txp:hide> =============  AUTHORS  =========== </txp:hide>
<txp:if_author>
  <txp:hide> + AUTHOR PROFILE + </txp:hide>
  <txp:output_form form="authors" />
<txp:else />
  <txp:hide> + AUTHORS GRID + </txp:hide>
  <txp:smd_if field="svrvar:REQUEST_URI, svrvar:REQUEST_URI" operator="ends, ends" value="author, author/" logic="or">
    <h1>Authors hall of fame</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 authors">
      <txp:smd_bio_info fields="RealName, author_photo">
      <li class="c33 m">
        <a href="<txp:site_url />author/{smd_bio_RealName}"><span class="author-photo"><img src="/images/{smd_bio_author_photo}.jpg" alt="{smd_bio_RealName}" /></span><span class="author-name">{smd_bio_RealName}</span></a>
      </li>
      </txp:smd_bio_info>
    </txp:smd_bio_author>
   </txp:smd_if>
</txp:if_author>

And then like I was originally going to try, by putting the author grid in it’s own section.

But in either scenario, when I try accessing a profile page, ../author/Destry+Wion, I see and get the same thing. Instead of a single author profile, I get a list of all author profiles. And instead of just the photo and name in the list, as the grid is supposed to be, it’s the entire suite of profile fields being output in the list.

I also get these errors at top of page:

Tag error: <txp:smd_wrap transform="textile"> ->  Textpattern Notice: unregistered_tag while parsing form authors on page default
textpattern/lib/txplib_publish.php:518 trigger_error()
textpattern/lib/txplib_publish.php:463 processTags()
textpattern/lib/txplib_misc.php(1783) : eval()'d code:1923 parse()
smd_bio_info()
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(1783) : eval()'d code:1645 parse()
smd_bio_author()
textpattern/vendors/Textpattern/Tag/Registry.php:83 call_user_func()

Tag error: <txp:smd_wrap_all wraptag="ul" class="biocaptionlinks"> ->  Textpattern Notice: unregistered_tag while parsing form authors on page default
textpattern/lib/txplib_publish.php:518 trigger_error()
textpattern/lib/txplib_publish.php:463 processTags()
textpattern/lib/txplib_misc.php(1783) : eval()'d code:1923 parse()
smd_bio_info()
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(1783) : eval()'d code:1645 parse()
smd_bio_author()
textpattern/vendors/Textpattern/Tag/Registry.php:83 call_user_func()

Tag error: <txp:smd_if field="andrewnhem" operator="begins" value="http"> ->  Textpattern Notice: unregistered_tag while parsing form authors on page default
textpattern/lib/txplib_publish.php:518 trigger_error()
textpattern/lib/txplib_publish.php:463 processTags()
textpattern/lib/txplib_misc.php(1783) : eval()'d code:2126 parse()
smd_if_bio()
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(1783) : eval()'d code:88 parse()
textpattern/lib/txplib_misc.php(1783) : eval()'d code:410 smd_wrap()
smd_wrap_all()

That last one is odd, even for me.

I hate to bother you with all of this. Are you still in the EU? I haven’t looked at the results. ;)

I once had a certain maniqui lending expertise on the CSF web team, but I think he’s neck deep in diapers these days; keeping a low profile. Bait as I try, he doesn’t bite.

Offline

#280 2016-06-23 13:53:53

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: smd_bio : store additional biographical info about your users

Bloke wrote #297063:

<a href="<txp:site_url />author/{smd_bio_realname}"> ... </a>...

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/">...

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.

I’m starting to think this is looking like a good Plan B, even with the 404 header issue.

Offline

#281 2016-06-23 14:07:21

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: smd_bio : store additional biographical info about your users

I’m going to let this sit for the rest of the day. All changes are current in the repo at the moment, in case anyone has nothing better to do.

Here are the three most relevant templates to the problem at hand:

Vote #remain!

Offline

#282 2016-06-23 14:32:23

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,453
Website GitHub

Re: smd_bio : store additional biographical info about your users

Destry wrote #299954:

Roger. I had created one called authors

That’s fine. I was going to suggest that, as it partially sidesteps the ‘cluttered front page template’ syndrome. Probably the best bet all round, ‘cos then you just put the list code in there, and the ‘individual’ code inside the <txp:if_author> on the front page template.

when I try accessing a profile page, ../author/Destry+Wion, I see and get… a list of all author profiles.

So your ‘authors’ Form is an smd_bio_author tag that displays the author read from the URL? e.g.:

<txp:smd_bio_author author='<txp:author title="0" />'>
   <txp:smd_bio_data blah blah>
</txp:smd_bio_author>

As far as I can recall, that should work. Been a while since I tried it though.

unregistered_tag

Ignore those warnings; they’ll go away in Live mode. The plugin tags just need registering, like I showed you in that code block above. All in good time…


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

#283 2016-06-23 18:23:01

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: smd_bio : store additional biographical info about your users

I think we’re getting closer, but not there yet. Here’s the authors form that intends to output the individual profile data:

<txp:smd_bio_author author='<txp:author title="0" />'>
<txp:smd_bio_info fields="RealName, bio, author_photo, caption, website, twitter, gplus">
	<article class="principle profile grid">
		<h1><txp:smd_bio_data field="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='Articles written'>
				<txp:smd_bio_articles wraptag="ul" break="li" author='<txp:smd_bio_data field="RealName" />' 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='<txp:smd_bio_data field="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:smd_bio_info>       
<txp:variable name="bio_found" value="1" />

</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>

For a while I wasn’t getting any output at all. But after fiddling with it (e.g. getting rid of some of the deprecated {smd_bio_whatevs}) I’m now at least seeing the variable check at the bottom; it’s outputting the…

Seems to be a problem
Can’t seem to pull up that profile. Let us know about it.

But that’s it. If the issue is in the syntax somewhere, It’s not jumping out at me.

Offline

#284 2016-06-23 18:30:01

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: smd_bio : store additional biographical info about your users

Maybe my attribute quotes are wrong on nested tags? But I’ve changed them around a thousand times at this point.

Another thing I’m hoping is possible, is if we can do some smd_wrap magic or something on the First+Last part of the URL so it appears in the address bar as first-last? The hope is that it will then make it easer to create 301 redirects on the URLs with a single rule instead of individual 301s for each profile link, if that makes sense. Something like this:

301 ../people/* --> ../author/*

Offline

#285 2016-06-24 07:11:14

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: smd_bio : store additional biographical info about your users

I decided to test my markup in the ‘authors’ form by hiding big pieces of it to see if I could isolate the problem spot. But even if I just leave this little bit in my “authors” form to pass — nothing but {RealName} in the h1 — it still doesn’t output anything on the homepage:

<txp:smd_bio_author author='<txp:author title="0" />'>
  <txp:smd_bio_info fields="RealName">
    <article class="principle profile grid">
      <h1><txp:smd_bio_data field="RealName" /></h1>
    </article>
  </txp:smd_bio_info>
</txp:smd_bio_author>

I’ve tried it with and without the <txp:smd_bio_info> wrapper, which I currently use to wrap everything inside the <article>...</article> region (a mix of smd_bio, smd_wrap, smd_if, and regular HTML tags). But, frankly, I can’t tell from the plugin instructions whether smd_bio_info tag is needed in this specific case or not, or if I can simply rely on all the smd_bio_data tags. In production with Txp 4.5.7 it’s working with smd_bio_info as a wrapper, but that’s not when trying to pass the author to the homepage.

The other thing I don’t quite get is how Txp knows to output the profile data on the homepage for the correct person whose name I click via the /authors section (the authors list). I guess that’s what the <txp:author title="0" /> in the opening smd_bio_author tag is for?

Offline

#286 2016-06-25 07:51:37

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,453
Website GitHub

Re: smd_bio : store additional biographical info about your users

Destry wrote #299961:

it still doesn’t output anything on the homepage

Very strange, because your snippet works for me on my home page:

<txp:if_author>
<txp:smd_bio_author author='<txp:author title="0" />'>
  <txp:smd_bio_info fields="RealName">
    <article class="principle profile grid">
      <h1><txp:smd_bio_data field="RealName" /></h1>
    </article>
  </txp:smd_bio_info>
</txp:smd_bio_author>
<txp:else />
   <txp:smd_if field="svrvar:REQUEST_URI, svrvar:REQUEST_URI" operator="ends, ends" value="author, author/" logic="or">
      AUTHOR LIST CONTEXT
   </txp:smd_if>
</txp:if_author>

I can’t tell from the plugin instructions whether smd_bio_info tag is needed in this specific case or not, or if I can simply rely on all the smd_bio_data tags.

smd_bio_data is an alternative to the old {replacement variable} syntax and is nothing more than a way to display individual fields when using smd_bio_info as a container. You can use smd_bio_info in its self-closing format with wraptag, break, etc to display a list of fields, or you can use it as a container and make your own markup.

These are all functionally equivalent:

<txp:smd_bio_info fields="RealName"
   wraptag="article"
   class="principle profile grid">
      <h1><txp:smd_bio_data field="RealName" /></h1>
</txp:smd_bio_info>
<txp:smd_bio_info fields="RealName"
   wraptag="article"
   class="principle profile grid">
      <h1>{smd_bio_RealName}</h1>
</txp:smd_bio_info>
<txp:smd_bio_info fields="RealName"
   wraptag="article"
   class="principle profile grid"
   break="h1" label="" />

but the {replacement} version is considered deprecated and may be removed in a future version of the plugin.

I guess that’s what the <txp:author title="0" /> in the opening smd_bio_author tag is for?

You guess correctly. If you output the <txp:author title="0" /> tag alone you’ll see it displays the user name of the person whose /author/full+name is displayed in the URL. All we’re doing is feeding that to the smd_bio_author tag to tell it which author to fetch from the database.


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

#287 2016-06-25 12:42:00

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: smd_bio : store additional biographical info about your users

Your snippet works. But I didn’t realize I needed the if_author wrapper and this:

<txp:else />
   <txp:smd_if field="svrvar:REQUEST_URI, svrvar:REQUEST_URI" operator="ends, ends" value="author, author/" logic="or">
      AUTHOR LIST CONTEXT
   </txp:smd_if>

What does that do?

In any case, we might be almost home.

My URL is appearing like this ../author/Destry%20Wion. If I change %20 to + it also works, but I’d prefer people didn’t see %20 at all. Even more, I’d love if there was some jiggery-poke to make the name appear as destry-wion. Maybe some smd_wrap with lowercasing magic and a symbol swap?

Offline

#288 2016-06-25 13:48:24

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,453
Website GitHub

Re: smd_bio : store additional biographical info about your users

Destry wrote #299971:

My URL is appearing like this ../author/Destry%20Wion.

How are the URLs generated? From smd_bio? Or from the code in your authors section? What does said code do? (paste here and I’ll take a look)

Regarding the extra smd_if bit and the else tag, you can take that lot out if you’re not using the home page as a landing area for /author (i.e. a list of all people). That bit’s handled by your dedicated /authors section, right?


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

Board footer

Powered by FluxBB