Textpattern CMS support forum

You are not logged in. Register | Login | Help

#271 2016-06-22 15:33:21

Destry
Moderator
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,339
Website

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

Destry
Moderator
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,339
Website

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:

  1. turn off gbp_permanent_links and smd_if plugins
  2. removed all instances of smd_if tags use
  3. 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">)
  4. 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

Destry
Moderator
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,339
Website

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

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,969
Website

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

Destry
Moderator
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,339
Website

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…

  1. 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
  2. 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

Destry
Moderator
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,339
Website

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

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

Destry
Moderator
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,339
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: 8,969
Website

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
Moderator
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,339
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
Moderator
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,339
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

Board footer

Powered by FluxBB