Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-08-11 15:28:30

zeusdidit
Member
Registered: 2007-10-16
Posts: 111

Using CODE in Articles

Hi.
I’ve come to realize that I can run scripts within articles. I imagine this is probably not a good thing to do, but I think it may actually be a great thing to do since I can give “Sections” their own search engine optimization, plus pull specific list types directly into the article.

So I was planning on making a couple of templates with different layouts, then using a specific article to layout the page. Does this make sense or is there a downside? Any suggestions are highly appreciated.

Offline

#2 2009-08-11 16:11:21

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: Using CODE in Articles

I prefer to keep my content and presentation separate. A better way to handle this would be to put your javascript into the form that gets used to output the article. You can even use conditionals and variables to grab stuff and customize the script. WAY cleaner.

Offline

#3 2009-08-11 17:08:32

zeusdidit
Member
Registered: 2007-10-16
Posts: 111

Re: Using CODE in Articles

Sorry, I’m confused. Not sure where the Javascript comes in. I usually have a Form to output all JS and meta when possible. Usually ::)

And wouldn’t the content and presentation still be separate if the Article titled “TXP Section My Stuff HP Page” uses <txp:article_custom section=“mystuff”> and in the section i just use something like:
<txp:if individual>
<txp:article form=“someform” listform=“somelistform”>
<txp:else>
<txp:article_custom id=“23” form=“body” /><!— doesn’t this sound just utterly terrible! i know! but it seems so sexy too! imagine the infinite possibilities of rendering—>
</txp:if individual>

I’m thinking it would turn the Section into a much simpler rendering container allowing me to have multiple or different article types with different looks for the Section’s content using just one template. I know I can have different Styles and different Forms, but in this last job I did, they required a bunch of different looks for each Section which really made the work more difficult and in some cases Forms weren’t rendering some types of data content. I can’t remember when it happened, but remember articles were more flexible. In fact I’m running
<txp:soo_article_filter expires=“past” >
<txp:article_custom form=“event_list_copy” pgonly=“0” section=“events” category=“Events” limit=“100” />
</txp:soo_article_filter>
<txp:article_custom category=“Historical” form=“event_list_copy” pgonly=“0” section=“events” limit=“100” />

Again, maybe I can run this type of argument using Forms, but why not use Articles?

Is there a downside to this type of usage? I ask because it appears that Articles allow conditionals and variables too.

I was considering having a Section called “Page Rendering” which would contain articles with different rendering of content.
And my other Sections such as, My Links, My Works, My Portfolio, My Blogs which would all use the template and style, ‘My Looks Styles.’
This would turn Sections into just containers pointing to one article which I can easily change by updating it’s Article ID. I would just use Forms for styling the content within the articles with the simple H1, Body, or Body, H1, etc for look and feels.

Or am I off the beaten path? Suggestions? Why shouldn’t I do this? Will this lag the DB?

Cheers ::)

Offline

#4 2009-08-11 17:21:58

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: Using CODE in Articles

OK, so now I’m a little confused about what you’re trying to achieve… sorry.

As a rule though, its much cleaner to alter presentation through css. So my approach would be to create a form for output that allowed conditional/contextual selectors (ID/class). That way you could have all kinds of per-content-item looks.

Offline

#5 2009-08-11 18:12:14

zeusdidit
Member
Registered: 2007-10-16
Posts: 111

Re: Using CODE in Articles

Thought this would happen. I’m thinking that the Articles could have different looks, similar to how Sections or Forms do them. On TXP’s site it talks about doing this for just one section, by calling the Article’s ID.

So I figured:
Section = Article Type
Category = Sub-Article Type
Pages = Container of Data
Styles = Container of Style
Forms = Container of Data formating
Article = Container of Data
Article Section = Container of Data Presentation (2 column, 3 column, tabular, lists)

Does this make more sense?

Is there a bad reason why I shouldn’t use this type of logic to build my next site?

Offline

#6 2009-08-11 18:50:52

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: Using CODE in Articles

So help me understand a bit better by telling me what you want to be the same and what you want to be different.

Something I consider to be elementary to the concept of site design is consistency in presentation by default and differentiation toward a purpose. So when I build, I start with everything looking the same, and moving toward things looking related but different where the need arises.

What are your common elements and what are the elements you want to change up? Perhaps throw in the kind of site you’re building and who it is geared toward.

Offline

#7 2009-08-11 18:56:24

zeusdidit
Member
Registered: 2007-10-16
Posts: 111

Re: Using CODE in Articles

let me get my thoughts down a bit better. i’ve drawn out an example that i’ll upload and send for you to see. it may help ;;)

Offline

Board footer

Powered by FluxBB