How to show the most recent games on your pages
Warning: since version 1.3 this block exists in default installation, so you don’t need to add it yourself. And in this case you can consider this tutorial as a tutorial about page blocks only.
So, let’s begin.
Step 1. Log in into your admin CP, open the "Page Blocks" tab and click the "Add Block" button. The form is quite simple, and you just need to fill it in as shown on the screenshot on the sidebar. I’ll just describe in few words what each value means.
- ID – this is a unique identifier or macro name you can use in any template to show this block. The script will replace it by the actual contents of the block, in our case by the list of games added recently.
- Block Type – simply choose what your block is – a php script or just a piece of static html code.
- Pages – on which page your block will be visible and on which it will not; you can quickly access these switchers on the list of blocks, I bet you saw a series of red/green buttons there.
- File Name – this is where your block’s code will be stored. Please note, you should not add file extension in this field, and of course, the filename must be unique.
- Title – in most cases this is used in the list of blocks in the admin CP only, but in this tutorial I’ll show you how to show this field as a caption of the actual sidebar block on your arcade website
- Max Elements – if your block shows a list of items, games for example, this field is very handy and lets you to define how many items it should show at once.
- Sorting – defines how to organize our list of items. The list can be sorted by date of addition, by gameplays, etc. In our block we (of course) should choose "By date added"
- Code – yes, this is the place for the block’s code – html or php.
Here is the values for our block:
ID: RECENT
Title: Added Recently
Block Type: PHP Script
Pages: Front, Category, Game
Filename: sidelist_sorted
Max Elements: 9 (or any other number)
Sorting: By date added
Comments: Anything
Code: Take the code from the code.php.txt found in the attached archive
Once all fields are filled, click the "Submit" button. The block is now created (but not functional yet.)
Step 2. Since this is a dynamic PHP block, it requires an html template to format the output. You should upload the "block_default.html" from the attached archive to your templates folder. The template has been made for "Toys" theme, but you can easity adapt it for using with other themes, just compare it with existing templates and make necessary changes in tags.
And the final, Step 3. We are almost done, the only thing we should do – place our block’s ID in the main pages’ html templates. To do that open the "Pages" tab inside admin CP (second screenshot) and edit all main pages as shown on the third screenshot – simply place !RECENT! where you would like to see them on your sidebars.
That’s it, now open your arcade site in browser and check how the new block is working
(You must be logged in to do that)
Proarcade's Twitter
