Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom Field or New Component?
#2
CustomFields are for when you have page specific fields that could apply for a multitude of pages. For example, you don't want to have a new component for every subtitle of every page you make or every excerpt of a news article (if you use i18n Search as a news plugin), so a CustomField is most suitable in that instance. These let you define relatively small pieces of information, but aren't really advised for direct HTML output or scripting.

Components are for when you need certain pieces of coding to be part of the template you're currently using (or in some cases, with mvlcek's DynPages plugin, outputting them on specific pages). So if you have HTML coding from an external site that you want to implement cleanly into your layout, or external Javascript etc..., components are the way to go. Scripting is friendliest via components, however these need PHP 'if' statements (or a separate template page) to make them page specific, so in contrast to CustomFields, these are more universal for pages. You only need to define them once for them to show up the same on all pages, whereas a CustomField needs to be defined for each individual page - that is the core difference.

Your situation sounds like you just want a few components running, some of which will be just for the homepage and another for the 'Latest News' page. Have a read of this topic for advice on page specific components in your template, and stick to simply using components if you have about 3 pages in particular that need special treatment. In essence, you'll be producing a PHP IF string that tells the browser "when the slug is index, the sidebar should output X component(s); when the slug is updates (just an example), the sidebar should output Y component(s); else the sidebar should output Z component(s) on any other page".

If it were a case of you needing a different component on every page and you had a large number of pages (for example having a multitude of available languages for your site), this method would prove messy with how many if statements you produce. Towards bottom of that topic in the link above there is an explanation by mvlcek of integrating both the CustomFields and components features to get a workable and practical solution.

Hope this helps you!
Reply


Messages In This Thread
Custom Field or New Component? - by designthing - 2011-06-12, 22:21:14
Custom Field or New Component? - by Angryboy - 2011-06-12, 23:20:56
Custom Field or New Component? - by designthing - 2011-06-13, 04:54:30
Custom Field or New Component? - by designthing - 2011-06-15, 20:55:38
Custom Field or New Component? - by designthing - 2011-06-16, 00:11:26
Custom Field or New Component? - by Angryboy - 2011-06-16, 01:03:09
Custom Field or New Component? - by Angryboy - 2011-06-16, 05:06:39
Custom Field or New Component? - by Angryboy - 2011-06-16, 05:25:52
Custom Field or New Component? - by Zegnåt - 2011-06-16, 05:37:36
Custom Field or New Component? - by mvlcek - 2011-06-16, 05:40:28
Custom Field or New Component? - by Angryboy - 2011-06-16, 05:47:34
Custom Field or New Component? - by designthing - 2011-06-16, 23:48:41
Custom Field or New Component? - by mvlcek - 2011-06-16, 23:59:43
Custom Field or New Component? - by designthing - 2011-06-17, 20:19:02
Custom Field or New Component? - by mvlcek - 2011-06-17, 21:36:05



Users browsing this thread: 1 Guest(s)