Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2024-08-30 13:24:40

Adams
Plugin Author
Registered: 2024-08-30
Posts: 38

First time user

First, thank you for all the hard work you guys have done with this CMS, and thanks for all the participants.

I’m new to this forum and a first-time user of Textpattern. A friend of mine recommended this CMS; so far downloaded, installed, looks straight forward, all done very well for any user, easy to use and understand. I hope I can move my complex old PHP site to this CMS. I’m not using it to publish articles; according to my friend, I can use it for what I need.

My first question is, is it possible to use ad hoc queries with external PHP files and attach them to a menu?

Offline

#2 2024-08-30 15:09:40

etc
Developer
Registered: 2010-11-11
Posts: 5,210
Website GitHub

Re: First time user

Hello, welcome to the forum and to txp in general.

As you have probably seen, you have the direct access to txp page/form templates, where you can include blocks of php code (if enabled in prefs):

<txp:php>
    echo 'Hello, world!';
    include('path/to/file.php');
    //etc
</txp:php>

Mixing php blocks with txp own tags should allow for whatever needed.

Have fun!

Offline

#3 2024-09-03 19:26:11

Adams
Plugin Author
Registered: 2024-08-30
Posts: 38

Re: First time user

Thank you; that worked.
It looks like I have to create a section to access it.
Is there a way to access a page by name?
Or is there a way to access an article by name or ID? 
I have 40 APIs used for multi-tier apps. If above is not possible, this means I have to create individual pages. 

Thank you

Last edited by Adams (2024-09-03 19:27:08)

Offline

#4 2024-09-03 19:59:26

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

Re: First time user

Adams wrote #337769:

It looks like I have to create a section to access it.
Is there a way to access a page by name?

No… pages hold blueprint markup and tags in which to inject dynamic content. They are tied to sections.

Most people reuse the same template for several sections that have similar layout characteristics, only deviating (via conditional tags or by creating a new page and assigning it to a section) when the layout is significantly different from other sections.

is there a way to access an article by name or ID?

Yes by ID. <txp:article_custom id="number">. Here’s the tag documentation for it.

But if your articles are all in sections. you can use the power of the <txp:article> tag to list and access them via browsing.


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

#5 2024-09-03 20:41:05

etc
Developer
Registered: 2010-11-11
Posts: 5,210
Website GitHub

Re: First time user

Adams wrote #337769:

Is there a way to access a page by name?

Not a page, but you can create a custom type form accessible via ?f=formname url.

Offline

#6 2024-09-03 21:09:40

Adams
Plugin Author
Registered: 2024-08-30
Posts: 38

Re: First time user

Thanks,
I assume you mean one section; let’s call it an API, and then create many pages all tied to the same API section.
page1, page2, page3, pages4
and then call site/api?page1 site/api?page2 so on.
Is that what you mean?

Offline

#7 2024-09-04 05:47:30

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

Re: First time user

Adams wrote #337775:

I assume you mean one section; let’s call it an API, and then create many pages all tied to the same API section.

No. It’s the other way around in Textpattern. One Section can only be assigned to one Page. But one Page can be used by more than one Section, so you can share layouts across Sections and benefit from less maintenance overhead: making changes to one Page template will update all Sections to which it is assigned.

You then create multiple Articles in that Section. They contain the content that is passed through the Page layout associated with it. If you call them page1, page2 etc then you would access each via example.com/api/page1, example.com/api/page2, etc.


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

#8 2024-09-04 05:58:32

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,734
Website

Re: First time user

In the Textpattern world, you’d:

  • define a page template with your HTML code and txp:tags to bring in content dynamically, set up navigation, sorting, filtering etc.
  • repeating sections thereof – partials if you like – are forms that you call from within your tags.
  • you set up a section, assign it the page template you would like it to show and start creating articles within that. With a clean-urls url scheme, you reach those via site.com/section-name/article-name which is a rewrite of the messy url scheme site.com/index.php?s=section-name&id=123.

You have a slightly different setup by the sounds of it.

If you want to process the code in a form without it having a page of it’s own, you can access it directly, as etc via the url site.com?f=formname. A typical use-case is a custom xml-feed or json block. In txp-use a form is usually only a part of a page – a header, page-nav, list item etc. – but there’s nothing stopping you making it an entire page that acts as your router for your own setup. You just end up with a longer/different url than if you used a section. e.g.

with form – independent of any textpattern site organisation

site.com/?f=formname&mypage=1&mylang=en

with a section and corresponding assigned page template:

site.com/section/?mypage=1&mylang=en

If you want to access your own url variables through textpattern tags, you can use the txp:page_url tag. The type attribute is preconfigured for typical textpattern situations, but you can also use it to obtain url variables of your own for processing on your page. The urlvar is sanitized.

If it helps, you can switch on the advanced settings under Admin › Preferences. You’ll see a new menu item where you can name your own form categories and optionally specify the mime-type with which they will be served (e.g. for an xml feed, or json).

If you need, on the other hand, to serve a section with a specific mime-type, you can use the txp:header to override the standard html output.

There are many ways…

EDIT: bloke was quicker. Again :-)


TXP Builders – finely-crafted code, design and txp

Offline

#9 2024-09-06 15:20:54

Adams
Plugin Author
Registered: 2024-08-30
Posts: 38

Re: First time user

Thank you, gentlemen.
I tried many ways, but none of them worked for me. I guess I will have all my API files outside. TXP.
I was hoping to be able to use TXP so I can update any file any time (as article or page) just logging to the admin site instead logging to the server or use FTP.

Thanks again

Offline

#10 2024-09-07 04:44:16

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

Re: First time user

If you could please give us more detail about what you’re trying to achieve and what your API does or how you (or users) expect to be able to use it, we should be able to help more.

At the moment we’re just guessing how you’re intending to use it and it’s tricky to visualise your workflow.


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

#11 2024-09-07 13:36:44

Adams
Plugin Author
Registered: 2024-08-30
Posts: 38

Re: First time user

Sorry, basically I have 47 PHP files, none of those accessed or used directly by the website or user. but all those used by applications/services to exchange data between clients and servers (send/get) responses with different types of data. currently accessed by a URL like this https://website/api/srv? + parameters and values 
srv is the API name to be called.
I was hoping to transfer those API files to TXP as pages, articles, or forms; this will allow me to fix or change any api file without logging in to the server.

Offline

#12 2024-09-07 13:38:59

Adams
Plugin Author
Registered: 2024-08-30
Posts: 38

Re: First time user

Also, all those files currently uses PDO connection type, I will change all to safe_query safe_update so on.

Offline

Board footer

Powered by FluxBB