Basic Concepts for Template Layout
|
This article discusses the basic ideas behind template layout and the key to getting the page builder to work.
See also Gallery Rotation See also Custom macro and query basics variables and formulas see also Talks about the default macros with no queries {{all-thumb-1}} Comus provides a set of tools for managing a database full of links to galleries, and a set of tools for building web pages automatically. Comus builds pages by reading HTML template files which it scans for {{macros}} and %variables% and replaces them with HTML for text links and thumb links to URLS. It gets the link and thumb information from a gallery database which is controlled via mysql. Once the first pages are built, Comus will run on auto pilot, periodically rebuilding the site, as long as it gets traffic. *Last updated Dec 18-2005* MACROS. There are several types of macros... Singular Layout Macros. Plural Layout Macros. Control macros Macros are divided into several parts... Basic Layout Macro form {{CATEGORY-TYPE-INDEX}} Where CATEGORY is the category type and can be... 1. {{all-thumb-1}} 2. {{Latin-thumb-1}} 3. {{custom(hidden)-thumb-1}} 4. {{%templatename%-thumb-1}} Example 1 is a basic singular macro which pulls new thumbs from all categories which are not hidden. Singular macros pull one thumb at a time, whereas plurals pull multiple thumbs at a time. Singular macros are identified by the type which in this case is 'thumb' and not 'thumbs', more explanation of plurals below. Example 2 is a basic singular macro that pulls new thumbs from ONLY the Latin category, you need enough thumbed and approved galleries within your Latin category to do this, or you will trigger errors and the replacement rules will kick in. Example 3 is a basic singular macro which will pull from the category called 'custom(hidden)' and only that category, the galleries of this category will not be available to any other category or query so you can use this to manage odd sized thumbs, or to single out your own custom galleries, note also that (hidden) categories are also hidden from the submit form, but the category will still be visible to you if you are logged into comus as administrator. Example 4, uses the first part of the template source filename to choose what category. IE if you have a source file called 'Latin.tmpl' and build to the Fred.shtml page, then this macro will pull galleries from the 'Latin' category. This enables you to build standard templates which can be re-used for other archives simply by changing the template source name. TYPE is the type of link to create and can be any one of.. Singular macro types. link archivelink thumb archivethumb Plural macro types. links archivelinks thumbs or archivethumbs Examples... 1. {{all-thumb-1}} 2. <table>{{all-thumbs-1-8}}</table> 3. {{Latin-archivethumb-1}} 4. {{Pornstar-link-1}} 5. <table>{{all-links-5-8}}</table> Example 1, is a singular thumb macro and will place 1 new thumb on the page, it will pull randomly from all categories but will ignore any galleries with the keyword 'hidden' in their category name. Example 2, is a plural thumb macro and will pull at random from all categories, it will create a 1 high x 8 wide table of thumbs. You must include your own table tags and this allows you to place style sheet info into the table tags. Example 3, will only pull from the Latin category, the archivethumb type will ALWAYS be pulled from the database AFTER the thumb type, so it is a way of making sure that you dont pull the newest galleries. Example 4, will create a textlink and not a thumb link, it will pull from the pornstar category and will pull a new gallery. Example 5, will create a table of text links 5 rows high and 8 cells wide, note that plural macros ALWAYS have the letter 's' on the end.. so {{all-thumbs-1-8}} is valid.. but {{all-thumb-1-8}} would NOT be valid and would fail. INDEX}} When using singular macros, the index must ALWAYS start at 1 and increase 1 at a time. IMPORTANT: If you change the category, type or query of a macro then you MUST start the index sequence again at 1. If you dont galleries will just come out in an unpredictable order. Example this is valid.
But this is NOT valid, because the latin index needs to start at 1 when the category changes.
And this is NOT valid because the type has changed and the thumbs and links need to have their own indexes.
This is not valid because each category needs to have it's own index starting at 1.
So this is valid...
You can mix plurals and singulars, this is valid..
But this is NOT.. because the TYPE has changed and plural and singular macros need to have their own indexes.
Thumb and link rendering order.. You might notice that plurals do not have indexes, they have dimensions, and therefore wonder in what order will the thumbs be drawn to the page? The general rule is that singular thumbs are always pulled before plural thumbs. So this might create undersirable results in the valid example above of mixed plurals and singulars. If you think about it, the newest thumbs there would come out in the singular spots and the very top row would have the left over older thumbs. In this case we can use the archivethumb type to control the build order. For example in this case the plural thumbs would be pulled before the singular archivethumb macros
But what if all macro types are the same, and there are no archive types, perhaps we have used nothing but plurals. Then the render order of thumbs is determined by the alphabetical order of their query names, and then their indexes. Therefore age0 gets processed before age1 and age2, etc. Note that this means the thumbs are NOT neccesarily rendered in order of their appearance on a page. They could actually be rendered from bottom to top, if you wanted to. In my standard prod booster templates I use 2 singular macros for the new thumbs, and then I use plurals for all the rest. This causes the new thumbs to be processed before any others, and then the age1,age2,ag3,age4 query names of the rest of the layout allows the thumbs to be pulled in the order that I want. This example is NOT valid..each macro block MUST be unique.
If you wanted to do something like the above you'd have to make the macros unique.. you can do this by incorporating the macro modifiers. There are 2 types of modifiers... prefixes and the query extensions, they are of the form... {{GROUP#SKIMRATIO#CATEGORY-TYPE-INDEX-COMMAND-QUERYNAME}} GROUP is one of the prefixes and can be added to a macro to force a group code from the macro on the page to be fed through to the trade script. GROUPS do not expect you to change the indexes. We can use GROUP to send tracking codes through to our trade scripts for example..
Will send the code T1,T2,T3,T4 through to your links via the %group% variable. If a macro does not have a GROUP setting then %group% will default to the gallery category. For example this variable can be added to your comus trade script prefix.. /trade_out.cgi?group=%group%&u= SKIMRATIO can be placed into macros to override the skim setting from your category section. By default the skim ratio from the category will be sent through to the trade script via the trade script prefix or suffix, unless it you specifically override it via this modifier. This allows you to skim at different rates for each thumb spot or row on your site.. for example.
The above code would skim at 80% on the top row, and 70% on the next row, and 65% on the next. You would incorporate this through the %tshave% variable, which is also found in the [Categories] page. This macro extension allows you to over-ride the [Categories] setting, but only when you have a trade script prefix that uses the %tshave% variable for example.. /trade_out.cgi?group=%group%&skim=%tshave%&u= Note that without the optional skim ratio extensions the macros would be invalid...
The reason is that there would be no way for the script to tell each row apart, whereas when we add the skim ratio each macro becomes unique. COMMAND is always just 'query', assuming we are extending the macro, if you leave the command out then comus will default to the 'new' macro so these three system macros are identical in purpose..
They are all just aliases of each other and will all pull new galleries from ALL categories. Note also that if you forget the -query- part, then the macro will error and probably render nothing but the macro itself. These are NOT valid and will cause errors
QUERYNAME is a reference to a set of rules, it follows the format of the mysql WHERE clause, you can go to mysql.org for more info on the WHERE syntax. The system standard queries will suit most people and you dont even need to define most queries as you'll find them in the examples, you can also examine the system standard queries by placing {{showqueries}} on your template, make sure to remove it when you are done. I do make the habit though of always defining my queries, it just makes it easier to read and debug. Custom queries are defined using the format. {{setquery-" blaaaa "}} where blaaaa is your query. You can find more info on Custom Queries here These are the standard queries that I use and you will find these the most trouble free..
Once defined a query can be used as a set of rules and applied to any query.
The queries I've definied above are the standard queries used by the prod booster system. Gallery life cycles. Whether daily or prod booster, the life cycle of a gallery is generally the same. 1. pull a new gallery or a set of new galleries in. 2. Move them through a first stage to collect clicks, 3. let the system age and advance galleries to the next stages. Cycle 1. pull in as new.. The galleries are aged via the periodsshown variable, if periodsshown=0 then the gallery is new. Periodsshown is a counter that increases by 1 for each day that passes once a gallery has been used as new. periodsshown will be 0 for galleries that are waiting to be listed. A basic new query.... {{setquery-new-" periodsshown>-1 order by periodsshown, rand() "}} and a basic new macro. 1. {{all-thumb-1-query-new}} 2. {{Latin-thumb-1-query-new}} Example 1 will pull new galleries from all categories, falling back onto the replacement rules if it should fail. Example 2 will pull new galleries but only from the Latin category, it will fall back onto the replacement rules if it should fail, and if it cant find replacements in the Latin category it will seek replacements from alternate categories, unless replacement rules are off and then it will just leave a blank spot. With prod booster the ability to pull new thumbs on every build will only work if the {{allowdupes}} or {{prodbooster}} macro is present on the page, if these macros are not present then the prod booster system will freeze up because Comus will only honour the new macros once per day. In the prodbooster templates we typically only have a single spot which requests new thumbs, and we control the total galleries used per day by the build frequency. IE a 10 minute refresh period, or build cycle would pull 144 thumbs per day or 6 thumbs per hour x 24 hours. This means for daily templates you need to remove the {{allowdupes}} and {{prodbooster}} macros from the pages that request new thumbs. And you will need to request a lot more thumbs, enough to cover your daily sections at least. And this means that prod booster templates do not easily transfer over to daily systems. By default we provide the prod booster system. Cycle 2. Move them through the first stage. In the case of prod booster, we lock galleries in with the stage1 query.
This sorts the galleries purely by their clickperiods, which is a count of how many builds have passed since the gallery was newly introduced. This macro causes the new galleries to cycle across the stage1 area, 1 step at a time, each time the site is rebuilt throughout the day. Once the galleries complete their march across the stage1 area, they are then released into the age1 area where they are sorted by click performance, usually we put age1 in a section called 'Todays Thumbs'.
In a daily template, where we select a limited amount of galleries for each day, we usually skip the stage1 area, and have a whole section of new macros followed by age1..
With daily must make sure NOT to have the {{allowdupes}} or {{prodbooster}} macros on the page.. or it will pull new thumbs constantly throughout the day. Once these macros are removed, you can build the page as many times as you like throughout the day, but the template will only pull new thumbs once per day. You might still want to build periodically throughout the day if you are loading a toplist into the page throughout the day. Rule#1: In order for a gallery to be able to appear in age1 it must first have been introduced as a new gallery via a 'new' query or via an age0 query. age0 is a sytem default query for new galleries. Pages will be built automatically by Comus, and new galleries will be cycled in on their own through as long as the site is getting traffic to its pages. The auto build does not need a cron job set up, as the builder is wedged into the HTML automatically. Warning: Because building is traffic driven, Prod booster needs at least 144 hits per day to function fully, if you dont have at least this much traffic the system will slow down and try to preserve the new gallery database until the traffic picks up again. You can get around this by setting up Cron Jobs to auto build your pages. There is an article on cron setup here You MUST make sure that you have galleries with thumbs and descriptions in Approved status in order for the templates to work. We provide these via the starter galleries. If you dont have enough galleries then you'll get a range of problems but most notably missing thumbs. The ideal minimum for prod booster is 2500 galleries which allows for around 14 days worth of history before rotation. |
||||||||||||||||||||||||||||||||||||||
|
Templates: When talking about templates here, I mean the code snippets that contain macros and HTML that we are feeding into the builder. These templates are actually found under the [Pages] icon. The templates contain standard HTML of your page and include special Comus {{macros}} which you put into the template and tell comus how to extract records from your database and how you want them to appear.
|