Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-07-07 13:40:30

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 689
Website Mastodon

Referencing a section by id?

Hello,
is there a way to reference a particular section in the database by an ID number?
Idealistically i would like to ask the database for a list of section names with a snippet of PHP in a form.
Those names would be set to be global, so that other form could reference particlaur section names correctly, even if the actual section names have been changed in the meantime.
Thank you very much for any hints!


A hole turned upside down is a dome, when there’s also gravity.

Offline

#2 2011-07-07 14:31:32

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Referencing a section by id?

Textpattern doesn’t assign static IDs for sections as the names are used as the identifier. You could probably alter txp_sections table and add an ID column which would be set as the tables auto_incrementing int. Would require changing the name column to unique from primary, and making the new ID column the primary. Thus, giving every section an unique everlasting ID, but still maintaining the uniqueness of the section names.

Offline

#3 2011-07-13 10:14:21

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 689
Website Mastodon

Re: Referencing a section by id?

Thank you, Gocom.

What i did now was setting up a form “all variables” mirroring my current section names using <txp:variable name="sect1" value="database-name-of-section-1" /> etc.

The form gets called as part of <head></head>, so that in any later situation i can reference a particular section by using <txp:variable name="sect1" /> etc.

That way i can make sure all my scripts continue working, whenever i desire to change the section names in the database, by simply mirroring the changes accordingly in “all variables”. Sweet!

Last edited by jayrope (2011-07-13 10:14:46)


A hole turned upside down is a dome, when there’s also gravity.

Offline

Board footer

Powered by FluxBB