Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#37 2020-09-04 19:09:08

gu
Member
Registered: 2020-08-27
Posts: 59

Re: Tag for static section on homepage only

Thank you Yiannis. I will focus on that now. I also thought I needed to create a section and page for categories, but either I did that wrong or it is not necessary. Greetings!


<!— space for hope —>

Offline

#38 2020-09-05 09:58:49

gu
Member
Registered: 2020-08-27
Posts: 59

Re: Tag for static section on homepage only

New process, ending with a key observation, if anyone cares to help with my attempt to make the search function work and have category URLs list the articles that are contained within them:
  • I made a search page with code like other pages except with this:
    <main> <txp:if_search> <h2><txp:permlink><txp:title /></txp:permlink></h2> <txp:search_result_excerpt /> </txp:if_search> </main>
  • I also made the search section with this input
    search_results
    search_results
    Zero
    search
    default
    default
    no no no
  • I had also (either with that section existing or not, just to try to learn through practice) included variations on search_results and search_input forms, always stored in miscellaneous.
  • An example form:
    <h2><txp:permlink><txp:title /></txp:permlink></h2> <txp:if_individual_article> <txp:body /> <div class="search-results"> <h2> Search results <q><txp:search_term /></q> </h2> <p>These articles match your search request:</p> <h3> <txp:permlink> <txp:title /> </txp:permlink> </h3> <p> <txp:search_result_excerpt hilight="p" limit="15" /> | <txp:permlink> <txp:permlink /> </txp:permlink> | <txp:posted /> </p> <txp:else /> <p>Sorry, we were not able to find a page matching your search request <q><txp:search_term /></q>.</p>
  • But I also tried versions like this:
    <txp:article limit="10" pgonly="1" /> <h2><txp:search_result_count text="search results" /> for "<txp:page_url type="q" />"</h2> <txp:article limit="10" /> <p><txp:older>&raquo; Next results &raquo;</txp:older></p> <p><txp:newer>&laquo; Newest results &laquo;</txp:newer></p> <txp:output_form form="search" />
  • Sometimes prefaced with variations of this:
    <h2><txp:permlink><txp:title /></txp:permlink></h2> <txp:search_result_excerpt />
  • None of that helped.
  • I appreciate this looks like I am playing coding lottery but this is because what I think I know is often wrong.
  • Maybe all I am missing is an anchor somewhere?
  • My best results were trying to include the code to search and categories on my default page – but because of how I have that set up (with too may txp_ifs), I was advised to search for a workaround and use a form. Maybe I just don’t know how to use the form correctly but I did randomly copy-paste form code from 4.9 and the ideal website forms to see if I could learn something from that code implementation (and see if it would work: it did not).
  • Most importantly: when I view the page source for searches or for when I click on the categories (note: my pages always have a nice list of categories displayed at the top, under the logo and search bar also always there), the <main> section always contains <txp:articles /> and never anything else even though I try to point the search and categories elsewhere. I am not only using a default page and have tried creating a category page with its own section (which seemed like an obvious solution to the problem) but that did not work – or, maybe I did not put the appropriate code on the page with its section.

<!— space for hope —>

Offline

#39 2020-09-05 15:58:51

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: Tag for static section on homepage only

You have : … <txp:if_individual_article> <txp:body /> <div class="search-results"> <h2> Search results <q><txp:search_term /></q> </h2> <p>These articles match your search request:</p>

Searches cannot be returned within an if_individual_article context, instead, they need to reside within an if_search one. Also, and please someone correct me if there are better methods, the tree should be something like.

<txp:if_article_list>
	<txp:if_section name='<txp:section />'>
		<txp:if_search>
			<txp:if_search_results>
			<txp:else />
			<p>no search results</p>
			</txp:if_search_results>
		</txp:if_search>
		<txp:else />
		<txp:if_category>
		</txp:if_category>
		<txp:else />
		</txp:if_search>
	</txp:if_section>
</txp:if_article_list>
<txp:if_individual_article>
</txp:if_individual_article>

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#40 2020-09-06 11:44:33

gu
Member
Registered: 2020-08-27
Posts: 59

Re: Tag for static section on homepage only

Thank you for your reply Yiannis, which I am grateful for as a form of encouragement. Above all, thank you for your time and input. I wanted to stop by to say that before getting back to working on the site. Have a lovely day!


<!— space for hope —>

Offline

#41 2020-09-06 15:04:23

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: Tag for static section on homepage only

gu wrote #325813:

Thank you for your reply Yiannis, which I am grateful for as a form of encouragement. Above all, thank you for your time and input. I wanted to stop by to say that before getting back to working on the site. Have a lovely day!

One good way of designing with txp is to do it without fluff. That is, use as few html elements as possible and no css. Once you know that the tags work as intended in the pages you wish them to appear, you can start adding the rest. In other words, do your app first and then work on the user interface.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#42 2020-09-06 15:49:21

gu
Member
Registered: 2020-08-27
Posts: 59

Re: Tag for static section on homepage only

Thank you Yiannis – I am on that very wavelength and have deleted things. Also, I am making progress!

I see I made many errors in my second to last post… I am tempted to correct it but above all want to say: thanks for the encouragement. A little wind for the solitary sail (not so solitary!)


<!— space for hope —>

Offline

#43 2020-09-06 21:41:41

gu
Member
Registered: 2020-08-27
Posts: 59

Re: Tag for static section on homepage only

>major edit follows, throughout post as I thought I had questions, but then found I was able to answer them myself, largely thanks to the input in this thread which I have revisited multiple times.

This post was once about making it to debug mode once I was sure, based on double-checking the advice here and on the tag explanations, that what I wrote was based on support.

I had a problem with <txp:article_custom frontpage=“1” sort=“Section desc” /> which got the warning Closing tag without corresponding opening tag: </txp:if_individual_article>.

I had problems caused by div class with txp combos. <txp:search_input /> appeared as a ‘form not found’ though it was on the page.

Output forms are magic. Thanks to Yiannis for continuing to recommend them – that must have been lodged in my brain to help associate the forms with these problems, even though I began by pursuing solutions based on wraptags, thinking the problem was caused by html class divs.

In conclusion, I do not think that I know how to use forums. It is too tempting for a person like me to think aloud and, in this instance, not be able to judge where or what is deemed useful to say because I am just so new at both forums and coding (to be fair, I did a little bit a while ago, but there are different levels of beginners). I can’t wait to get over this beginner’s slump but thank you for contributing to what is a safe community to grow. If I succeed in growing, you will be the village that raised me :)

I would really like to clean up previous comments, but maybe they are a source of fond memories for some as they remember their own first steps, or a prompt for a gentle chortle. But if anyone thinks I could scrap some of them to tidy up this thread I would be more than happy to. I cannot believe how even I myself can see just how messy they are in such a short time (though inclusive of both nights and days). I hope to have my little program to share soon, but I am not quite done. Cheers to this most lovely forum.

Last edited by gu (2020-09-07 10:32:57)


<!— space for hope —>

Offline

#44 2020-09-07 11:14:23

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Re: Tag for static section on homepage only

I rarely reply re technical things on this forum, usually leaving it to those who are very clear about tags and coding, but maybe others are very busy so I’ll have a go, gu, and hope I don’t confuse you.

gu wrote #325824:

I had a problem with <txp:article_custom frontpage=“1” sort=“Section desc” /> which got the warning Closing tag without corresponding opening tag: </txp:if_individual_article>.

<txp:if_individual_article> ends with </txp:if_individual_article> and the warning simply states either <txp:if_individual_article> is missing, or perhaps you spelt it wrong or there’s an extra > or something like that.

I had problems caused by div class with txp combos. <txp:search_input /> appeared as a ‘form not found’ though it was on the page.

Perhaps you had <txp:search_input /> on the page, but does it exist in your list of forms? Have you changed its name, perhaps to search-input or something like that?

In conclusion, I do not think that I know how to use forums….

You’re doing fine, don’t worry about it, we all make mistakes and say things that embarrass us later that we wish we’d never said. But at the time we didn’t know as much as we know now, or perhaps we weren’t having a good day. We’re all human beings on here (except developers who are super-human pretending to be quite normal :) so we’ve all been through stuff similar to your experience. I’m looking forward to seeing your little project, it sounds intriguing.


BB6 Band My band
Gud One My blog

Offline

#45 2020-09-07 13:00:56

gu
Member
Registered: 2020-08-27
Posts: 59

Re: Tag for static section on homepage only

Hi Zero, so appreciate your message! Truly!!!

In the mean time, here is some news: I can’t believe it but I finished my little site! No more bugs!

Since I have found WC3 markup validation to kind of be like a Magic 8 Ball: sometimes revealing new problems simply by entering the website address at a different time of the day, I will let the site rest and then recheck it. Then I’ll try to check for redundancies. And then I’ll share it.

I am reading the Themes: Creating, Using, Sharing page now and expect that will be a learning process too but I hope to have this out by next week.

Thank you for being so supportive of “beginner’s mode” :)


<!— space for hope —>

Offline

#46 2020-09-07 14:35:21

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

Re: Tag for static section on homepage only

Hi, gu. Your journey here in the forum is important to keep as documentation, and as an aid to help others learn. I’ve been here nearly fifteen years and posted a ‘problem’ just yesterday that I couldn’t fathom, only to find the answer obvious when someone pointed out that I was using the wrong version of Textpattern that was too old for the feature I was trying to implement! Happens to us all, so don’t worry.

That said – and I don’t want to patronize you or anything here so please forgive me if it comes across that way – here are a few general Textpattern tips that might help in your orientation:

Textpattern ‘list’ tags that operate to display collections of context-aware things (articles, images, categories, sections, files, comments, and so forth) can be used in three fundamental ways:

1) As a container – a pair of opening and closing tags:

<txp:some_list_tag wraptag="div" class="my-wrapper">
   Display <txp:dynamic_facets /> of <txp:each_thing /> in the collection.
   This allows you to customise how the content of each item is laid out.
   The entire set will be wrapped in <div class="my-wrapper">list of things</div> as dictated by the tag's attributes.
</txp:some_list_tag>

(<txp:dynamic_facets /> and <txp:each_thing /> aren’t real tags, they’re just to show that you can put <txp:> tags in to display dynamic information from the database/content anywhere you like)

2) As a single self-closing tag with the form attribute:

<txp:some_list_tag form="reuse_me" wraptag="div" class="my-wrapper" />

The entire set of items will be wrapped in <div class="my-wrapper">list of things</div> as indicated by the list tag’s attributes.

Then, in Presentation>Forms, create a form (of any type) called reuse_me with tags and content such as this, that you wish to display for each item:

Display <txp:dynamic_facets /> of <txp:each_thing /> in the collection.
This also allows you to customise how the content of each item is laid out.
The same Form can be reused for other tags so it's easier to manage in future.
Change your layout or content in the form and your site updates automatically wherever this form is used.

3) As a single self-closing tag without the form attribute:

<txp:some_list_tag wraptag="div" class="my-wrapper" />

This will operate exactly as in (2) but it will use a pre-defined form name. In the case of articles, this will be one called default. So if you modify that form, you change how every article tag that uses it behaves.

So any time you want to override the default behaviour of some ‘list’ tag, you specify a form attribute so the tag will display the content in that form when your page is displayed and it encounters that tag. This concept follows in some other non-list tags too. In the case of <txp:search_input />, for example, it looks for a corresponding search_input form. If that form doesn’t exist, the tag will throw a warning (in debugging mode).

Some tags don’t accept form because they output a specific piece of information. The <txp:title /> tag, for example, will only output the article title of the current article indicated by the visitor’s /section/some-article URL. Or, if used in a form or container, the article title of each item in the collection.

So when you’re debugging a Textpattern page, you need to be mindful of how a tag is being used.

If it’s a ‘single’ (self-closing) tag, it’ll output the given context-aware content when the tag is encountered as the page is displayed.

If it’s a self-closing ‘list’ style tag and has not been given a form it will use a default form to display content for each item in the collection. The default form that will be used in each case are all mentioned in the tag docs.

If it’s a self-closing ‘list’ style tag and has been given a form, it will use that form for each item in the collection. It’s up to you to ensure that form exists and uses relevant tags for the context in which the form is used.

If the ‘list’ style tag is used as a container, then the content between the opening and closing tags will determine how each item in the collection is displayed. It’s up to you, again, to use relevant tags for the context. So, for example, if you’re displaying a list of site sections:

<txp:section_list wraptag="nav" class="site-sections">
   <a href="/<txp:section />"><txp:section title /></a>
</txp:section_list>

Is perfectly valid (although you can do the same thing with a simple self-closing tag in this case, since that’s the output the tag creates by default). But you cannot use, say, <txp:title /> in that container, because Textpattern is in “section list” context at that moment and has no idea what ‘article title’ means.

In short, be aware of context and which forms are being used for what. If I ever get stuck and not sure which form is being used, I’ll type some random text string into the top of the form I think should be in use, save it and refresh the page. If that text appears on the page, the form is in use. I can then delete the text string safe in the knowledge that the form I’m working on is the one being used in that context. This practice, although old-skool, is still quite handy, and comes into its own when you’re messing around with themes and need to be sure that the form you’re working is the one in the theme you expect.

Hope that helps.

Last edited by Bloke (2020-09-07 14:38:43)


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

#47 2020-09-07 17:33:01

gu
Member
Registered: 2020-08-27
Posts: 59

Re: Tag for static section on homepage only

Dear Bloke, receiving a gem like that is certainly worth making public my waffling; I write half in jest :)

In all seriousness, I have come across your contributions here on the forum and to key textpattern github material while reading up on txp and I’d like to say what a special forum this is when experts like you also stop by and help beginners with their first steps.

Thank you so much for sharing that lesson!


<!— space for hope —>

Offline

#48 2020-09-09 14:37:29

gu
Member
Registered: 2020-08-27
Posts: 59

Re: Tag for static section on homepage only

>Update: It is now in order and images of sample pages have been added to the wiki. The ‘about’ blurb contains thanks to the forum (thanks is also included in the code). I know it is a simple project, but you were all such help. Thank you again.

Here is a link to the very simple theme I built on the Zero install: https://github.com/temene/tem. The branches are not yet in order but I just wanted to stop by because it is ‘live’.
If I have made any mistakes, I would be so appreciative if you would let me know.
Thank you so much to all of you for your assistance. Please let me know if I can be of help in any way. On my end, I will be spreading the word of textpattern!

Last edited by gu (2020-09-10 18:21:58)


<!— space for hope —>

Offline

Board footer

Powered by FluxBB