Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#21 2020-09-01 11:05:10

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 3,131

Re: Tag for static section on homepage only

gu wrote #325702:

As for making the website ‘public’ (I know it is available to crawlers, but I expect it to remain in a back corner of the web), I am definitely internet shy. I am also responsible for contributors so am reluctant about posting the site address as a general principle.

Totally understandable, and agreed – I edited your post rather than making a fresh reply so you can zap the link when you’re ready to. The TLS for your site wasn’t working when I checked, hence the http link.

Offline

#22 2020-09-01 11:13:43

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

Re: Tag for static section on homepage only

Thanks for that!


<!— space for hope —>

Offline

#23 2020-09-01 12:10:13

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,269
Website

Re: Tag for static section on homepage only

As the #4 article only appears as an excerpt in the front page, I do not think that it needs to be a sticky one unless you wish of course to exclude it from the list of articles, as etc suggested.


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
I do my best editing after I click on the submit button.

Offline

#24 2020-09-01 12:17:10

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

Re: Tag for static section on homepage only

Indeed, I did not want the sticky to appear twice on the homepage. I might make more stickies to appear in that fixed position in the future (which is such a neat feature of the id attribute) so really, that would not be good.
The problem of the sticky url not displaying page content applies to all stickies. Everything else works – the (multiple) id attribute of the custom article, the sticky status…
The missing body of the URL remains a mystery.
As for the search problem, I am now discovering that I possibly did not include the full range of txp code that is needed. TBC.
My site name on display is haunting me so I will take it down now but if there is an option to share privately and if any old hands want to help if this issue persists (one remains hopeful that it won’t) I will share it.
Thank you again to everyone!

Last edited by gu (2020-09-01 12:17:47)


<!— space for hope —>

Offline

#25 2020-09-01 12:59:19

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,269
Website

Re: Tag for static section on homepage only

I am using custom_fields instead of stickies. For this page for example, I am using a custom_field named c10, to separate current/featured blog posts from the rest. You can check how I have done it on github. Note that the name of the form I am using, sticky_form, is a legacy name from the time I was actually using sticky articles. I just find CFs easier to handle and manipulate:)


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
I do my best editing after I click on the submit button.

Offline

#26 2020-09-01 13:35:39

etc
Developer
Registered: 2010-11-11
Posts: 3,863
Website

Re: Tag for static section on homepage only

gu wrote #325707:

As for the search problem, I am now discovering that I possibly did not include the full range of txp code that is needed.

By default txp uses search_results form to output search results, please check whether it exists. Also, putting the site in debug mode might help.

Offline

#27 2020-09-01 14:41:42

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,269
Website

Re: Tag for static section on homepage only

etc wrote #325711:

Also, putting the site in debug mode might help.

Just wanted to add that, when the site is on debug mode, you will be able to see a tag trace, and possible errors, in the source code of the page your are trying to troubleshoot.


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
I do my best editing after I click on the submit button.

Offline

#28 2020-09-01 20:21:54

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

Re: Tag for static section on homepage only

> edited: misspelled name
> edited again: I don’t see colak’s signature anymore. It said something to the effect of doing one’s best editing after pressing publish.

tl;dr Currently, I have what used to be the static pages displayed at the top of the articles ‘feed’ but they are also repeated further down. And this new solution has now garbled the way the page is displaying on mobile screens.

What a past few hours it has been (but very interesting: I try to encourage myself by saying that as I try to find the solution I am also learning new things).

- colak – I tried variations of your hack (and rejoiced at the boolean). Also – I just realised that your signature is my spirit animal.

- etc thank you for that suggestion – given the problems I’m now facing, I strongly suspect there is a problem with a bug. I guess it is because I am not using just the default page but also an article form because that made it possible for comments to only appear on articles and not on the home page.
But I do not know how to find bug mode and my cursory internet search did not help. (It is time for a break… but so hard to learn discipline to let these problems go in order to get the rest needed by human beings.)

In closing, and to dompt the tension I feel, I’d like to express the marvel I felt when looking at colak’s code when I realized that I understood some of it. I looked at the boolean solution which was just another way of the <txp:if_article_list> and <txp:if_article_list not> solution and thought: how beautiful this all is!

Last edited by gu (2020-09-01 20:27:17)


<!— space for hope —>

Offline

#29 2020-09-01 22:03:03

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 3,934
Website

Re: Tag for static section on homepage only

You mentioned above that you’re using the “zero” theme, and while that gives you a clean slate to start with, it is also lacking some of the default txp forms (under Presentation › Forms) that Textpattern uses to display standard content.

I suspect that is why you see no search results when adding a search term. As etc mentioned, txp uses the search_results form to output search results unless you explicitly specify a form of your own.

Similarly, the individual article display (i.e. when the URL is site.com/section/article-name) uses the default form by default and the article_listing form for listing pages such as on the default page, a category filter or a section landing page. If you don’t have those forms in your theme (and don’t specify an alternative form of your own), you won’t see the expected output.

Those may also explain why you’re seeing no article body output when visiting an individual page.

sticky url not showing twice in a listing

sticky url not showing when you visit it

By default the standard txp:article tag uses status="live" (as detailed in the docs). That means it will not display sticky articles.

For your article_list view on the homepage, you can use this to stop it showing twice. Your txp:article_custom id="4" status="sticky" will show it explicitly, but the txp:article tag further down will only show live articles.

If you want your sticky articles to be visitable via an url, you need to employ a trick in your individual_article case:

<txp:if_individual_article>
    <txp:article status="sticky" />
    <txp:article status="live" />
</txp:if_individual_article>

While this may at first seem illogical, because this code only kicks on an individual article page, it will use either one or the other tag, depending on the current article’s status.

If you are using a sticky article just to show some intro text (without a page to click through to), you don’t need this at all. See instead the container-tag example below.

the form="myform" attribute vs. no form vs. container tag usage.

You can use txp:article , txp:article_custom, and many other tags that use forms in different ways.

  • If you provide no form attribute at all, the tag will use a default form name. See the docs for the name of the form txp looks for.
  • If you provide a form="myform" attribute with a name of your own choosing, it will output the contents according to what you put in the myform form.
  • In cases where you just want some quick output once-only, you don’t have to define a form in every instance. Instead you can use the tag as a container like this:
<txp:article_custom id="4" status="sticky">
    <div class="intro-blurb">
        <txp:excerpt />
    </div>
</txp:article_custom>

debugging mode

You can switch to debugging mode by visiting Admin › Preferences › Site Preferences and looking for the Production Status dropdown. Choose “Debugging” and click Save to change the status. The different production statuses are described in the docs here.


TXP Builders – finely-crafted code, design and txp

Offline

#30 2020-09-02 14:51:30

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

Re: Tag for static section on homepage only

> edit: closing bracket. I am making this edit in a bid to teach myself how to reach “flow” (cf. Csikszentmihalyi) in commenting. At the moment I am still a little nervous about forums, which causes sloppiness. How did you all learn this etiquette, I wonder?

Thank you Jakob for your detailed post. I don’t know if I should stop posting here with responses (I honestly don’t know enough about the ways forums work, so if I overstay my welcome, please, someone let me know, especially because I am such an ignoramus and have extended the scope of my original question). I’ve decided, for now, to share further thoughts in case they are relevant to development.
  • Yes, I am working on Zero but to be clear I did fill in a Form with code for the default page – this included the txp to retrieve body (with heading) and the txp for comments and relevant posts.
  • It turns out the search function works but with limited results. For example, I had several articles with the word “article” in the headline – searching for “article” led to positive results. But searching for words within posts was not effective. I wonder if this is because I do not know how to include the “aria” code.
  • The code snippet that you were so kind to share was also able – like the other hack I invented for myself (making the articles on the home page show only those posts destined for the homepage [using the boolean custom_article attribute]) – to list those articles successfully on the homepage – but with the same problem of the URL no longer leading to the content written in the body of that article. I tried different placements of the last line of that code but in all cases, the URL of the article did not deliver the body.

If anyone is following along with my story and using my woes for entertainment :), I actually totally rewrote the code for the site yesterday (! time suck) in a much cleaner way, but this led to new problems. I have another site with the old code on it (also not currently in official use), so I did not lose the satisfaction of at least having the appearance that I can make something that looks good but am trying to develop good habits even if this means starting all over again. An example of why: in the version that looks good, my css had .entries except for body, which, when prefaced as .body would totally throw off the page appearance.

I consider that must surely be because of poor programming and since I want to share my Simple Txp (I have no illusions at how little of a contribution this is! but for me it would be a great achievement) I want to present something that avoids any errors I can see. As a beginner, I know there will likely be errors I cannot see but I am trying to avoid that by reading up on every code snippet I use.

A final (working) thought: txp is the enthymeme to syllogisms in code. Ok, off to work on the site now. Thank you forum for all of your kindness and support.

Last edited by gu (2020-09-02 15:01:28)


<!— space for hope —>

Offline

Board footer

Powered by FluxBB