Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2017-08-09 20:38:36

etc
Developer
Registered: 2010-11-11
Posts: 2,363
Website

Re: txp:article_custom via php echo

macosa wrote #306558:

Thank You! Im building like this. Its great i think ))))

Not yet, I think this should do what you need faster:

<txp:article_custom  section="trips" limit="999">
<txp:php>
global $thisarticle;

if (abs($thisarticle['geolatitude'] - $_GET['geolat']) < 4 && abs($thisarticle['geolongitude'] - $_GET['geolong']) < 7) {
    echo output_form (array('form' => 'map_clusters'));
}

</txp:php>
</txp:article_custom>

etc_[ query | search | pagination | date | tree | cache ]

Offline

#12 2017-08-28 16:00:28

zenman
Member
Registered: 2017-08-28
Posts: 16
Website

Re: txp:article_custom via php echo

Hello!

Is there any way to make txp:article_custom work with url ? Something like this:

<txp:article_custom url="page.html" /> 

I assume it can be done using the url field somehow through php?

Last edited by zenman (2017-08-28 16:04:35)

Offline

#13 2017-08-28 16:50:29

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 6,238
Website

Re: txp:article_custom via php echo

zenman wrote #306742:

Hello!

Is there any way to make txp:article_custom work with url ? Something like this:

<txp:article_custom url="page.html" />...

I assume it can be done using the url field somehow through php?

Hi zenman and welcome to txp.

The short answer to your question is No.

You can however, if the url you wish to show is part of the txp database, use: <txp:article_custom id="45" /> – You have to of course replace the id number to the id you wish to parse. You can read more about the article custom tag in the documentation.


Yiannis
——————————
neme.org | hblack.net | LABS | NeMe @ github

Offline

#14 2017-08-28 16:58:54

zenman
Member
Registered: 2017-08-28
Posts: 16
Website

Re: txp:article_custom via php echo

colak wrote #306743:

Hi zenman and welcome to txp.

The short answer to your question is No.

You can however, if the url you wish to show is part of the txp database, use: <txp:article_custom id="45" /> – You have to of course replace the id number to the id you wish to parse. You can read more about the article custom tag in the documentation.

Thanx. Oh, how sad. Yes, I know about Article_ID. Is there any other way I can get an article by its url?

Last edited by zenman (2017-08-28 17:01:35)

Offline

#15 2017-08-28 19:49:16

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 3,943

Re: txp:article_custom via php echo

zenman wrote #306744:

Is there any other way I can get an article by its url?

Could you describe a little what you want to achieve and why you think the best way to do this is via article URL? Maybe someone could offer some other way to solve it. E.g. if you want to use a URL parameter to call an article, then you might want to have a look at adi_gps.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#16 2017-08-29 06:50:40

zenman
Member
Registered: 2017-08-28
Posts: 16
Website

Re: txp:article_custom via php echo

uli wrote #306746:

Could you describe a little what you want to achieve and why you think the best way to do this is via article URL? Maybe someone could offer some other way to solve it. E.g. if you want to use a URL parameter to call an article, then you might want to have a look at adi_gps.

Hi. Well, i think using article_id is better than article_url. Therefore my question is not important anymore. Furtheremore, i have solved it through a custom_field, but still article_id is better.

What i wanted to achieve is to use parent and children articles using categories with the same urls as those of articles. But I have found that naming a category as article_id is more convinient. Something like here

The code example with article_id

<ul class="Parent-Articles">
<txp:article_custom section="your-section"  limit="999">
<li><txp:permlink><txp:title /></txp:permlink></li> <!-- list of parent articles -- >
<ul class="Child-Articles"><!-- list of child articles if category name is the same as parent artilce's ID. If not, nothing will be displayed -- >
<txp:article_custom  category='<txp:article_id' limit="999">
<li><txp:permlink><txp:title /></txp:permlink></li>
</txp:article_custom>
</ul>
</txp:article_custom>
</ul>

Last edited by zenman (2017-08-29 07:02:03)

Offline

#17 2017-08-29 08:24:14

jakob
Moderator
From: Germany
Registered: 2005-01-20
Posts: 2,651
Website

Re: txp:article_custom via php echo

Yes, that could work. Your example from that site has a small syntax error (missing closing tag for <txp:article_id />) and produces invalid HTML (for the nested ul-lists). It can also be made more succinct by including wraptag, class, and break attributes in your article_custom tag. That way nothing is shown if there are no relevant articles (in the above example, you get an empty <ul></ul> for every article without sub-articles).

However, even with the changes below, I think you may run into the problem that the child articles (if they are also in the section your-section) will be listed twice in the output, once as a child-article and once in the main list. You’ve no way of excluding the child articles from the main list. To achieve that you would need to put the child articles in another section.

<!-- list of parent articles -->
<txp:article_custom section="your-section" limit="999" wraptag="ul" class="Parent-Articles" break="li">
    <txp:permlink><txp:title /></txp:permlink>

    <!-- list of child articles if category name is the same as parent article's ID. If not, nothing will be displayed -->
    <txp:article_custom category='<txp:article_id />' limit="999" wraptag="ul" class="Child-Articles" break="li">
      <txp:permlink><txp:title /></txp:permlink>
    </txp:article_custom>

</txp:article_custom>

The classical way to achieve the pattern shown in that article is to use sections and articles.

About [section] – Parent article [sticky]
Services [section] – Parent article [sticky]
service 1 – child article [live]
service 2 – child article [live]
service 3 – child article [live]
Contact [section] – parent article [sticky]

Rather than using categories, create a section for each menu item, e.g. here “about, services, contact” and assign articles to each section. For the top-level landing page, set the article status to “sticky”, the sub-articles to “live”.

<!-- main sections menu -->
<txp:section_list sections="about,services,contact" wraptag="ul" class="parent-sections" active_class="active" break="li">
  <txp:section link="1" title="1" />

  <!-- articles in <txp:section /> section -->
  <txp:article_custom section='<txp:section />' limit="999" wraptag="ul" class="child-articles" break="li">
    <txp:permlink><txp:title /></txp:permlink>
  </txp:article_custom>

</txp:section_list>

Then, on your template for each section use txp:article with status="sticky" to display the landing-page article.

You only need the parent/category way, if you need a third tier, i.e. you are already using sections and need parent/child articles within one section. And if that is what you do need, you might find parent/child categories a more effective way of avoiding double article output.


TXP Builders – finely-crafted code, design and txp

Offline

#18 2017-08-29 20:02:13

zenman
Member
Registered: 2017-08-28
Posts: 16
Website

Re: txp:article_custom via php echo

jakob wrote #306754:

Yes, that could work. Your example from that site has a small syntax error (missing closing tag for <txp:article_id />) and produces invalid HTML (for the nested ul-lists). It can also be made more succinct by including wraptag, class, and break attributes in your article_custom tag. That way nothing is shown if there are no relevant articles (in the above example, you get an empty <ul></ul> for every article without sub-articles).

However, even with the changes below, I think you may run into the problem that the child articles (if they are also in the section your-section) will be listed twice in the output, once as a child-article and once in the main list. You’ve no way of excluding the child articles from the main list. To achieve that you would need to put the child articles in another section.

<!-- list of parent articles -->...

The classical way to achieve the pattern shown in that article is to use sections and articles.

About [section] – Parent article [sticky]...

Rather than using categories, create a section for each menu item, e.g. here “about, services, contact” and assign articles to each section. For the top-level landing page, set the article status to “sticky”, the sub-articles to “live”.

<!-- main sections menu -->...

Then, on your template for each section use txp:article with status="sticky" to display the landing-page article.

You only need the parent/category way, if you need a third tier, i.e. you are already using sections and need parent/child articles within one section. And if that is what you do need, you might find parent/child categories a more effective way of avoiding double article output.

Thanks for noticing syntax error, in real time textpattern would show that. Sections are ok if you use four or five like about, articles, contact, etc.

Managing too many sections with two or three child articles is not always very convinient. Then what if one needs several subsection with just a couple of child articles? Does it make any sense to create so many of them? With article_id categories it is much easier to administer articles.

One can easily exclude child articles from the main list by adding parent articles to a separate category.

Example (sorry, it is not in English but the idea is understandible): http://cargoalliance.ru/geo/
Parent articles are with flags and their child articles are below under article_id category. I think using so many sections with flags instead of articles would be too tiresome.

I tried to connect articles and categories with url but realised that article_id was a better decision because I can see ids right in the lilst without opening them.

Offline

#19 2017-08-29 20:47:17

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 3,943

Re: txp:article_custom via php echo

Hi zenman, the email link has a typo (lacks 1 small L). That’s the stuff my attention springs at ;)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#20 2017-08-29 22:23:44

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: txp:article_custom via php echo

zenman, You can create categories with the same names as the url_title of the parent articles.

For example, a category tree can be:

country
	china
	hongkong
	europe
	...
  • All parent articles has category = “country”
    • First parent article has url_title = “china”
    • Second url_title = “hongkong”
    • url_title = “europe”
  • Child articles have one of the categories: “china”, “hongkong”, “europe”. And have any url_title.

A slightly modified jakob code.

<!-- list of parent articles -->
<txp:article_custom category="country" limit="999" wraptag="ul" class="Parent-Articles" break="li">
    <txp:permlink><txp:title /></txp:permlink>

    <!-- list of child articles if category name is the same as parent url_title. If not, nothing will be displayed -->
    <txp:article_custom category='<txp:article_url_title />' limit="999" wraptag="ul" class="Child-Articles" break="li">
      <txp:permlink><txp:title /></txp:permlink>
    </txp:article_custom>

</txp:article_custom>

On one of my projects, I used a similar approach.


aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

Board footer

Powered by FluxBB