-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shortcodes guide #5
Comments
Shortcodes:AdminThese shortcodes are those used in the admin area of your site. Contents [hide] {ADMIN_ALT_NAV} Unlike most shortcodes, this shortcode requires an additional measure to use. You need to add this code to your theme.php: Code: theme.php snippet
If you would like to style the menu by overriding the default style, copy e107_files/nav_menu.css to your themes root directory. Edit the CSS as you wish and then change the above code you entered into your theme.php to: Code: theme.php snippet
You can also tailor the javascript itself to your requirements by copying e107_files/nav_menu.js to your themes root directory and editing it as needed. To change the image icons displayed in the menu please read the section of this manual on admin icons. A front end version of this menu is also available in core by adding the shortcode {SITELINKS_ALT} to your theme.php. This will share the same stylesheet as your admin menu that we required above so the two menus will match in style. {ADMIN_DOCS} {ADMIN_HELP} {ADMIN_ICON} Plugins are also able to register a 32px x 32px icon which will also be displayed by this shortcode when the user is on the plugins admin config page(s). If the plugin doesnt have this icon, then a generic plugins icon will be displayed instead. {ADMIN_LANG} {ADMIN_LATEST} Plugins are also able to register to display information in this menu, for example, the forum plugin registers with the menu to display the number of reported forum posts since the admins last visit. For details of how to enable your own plugin to display in this menu, please see the relevant page in the plugin coding section of this manual. There is an optional parameter with this shortcode which instructs it only to display when a page requests it. To use this feature, add the =request parameter to the shortcode in your admin_template.php like this: 1. {ADMIN_LATEST=request} {ADMIN_LOG} {ADMIN_LOGGED} {ADMIN_LOGO} {ADMIN_MENU} You can style this menu by copying the show_admin_menu() function in e107_admin/header.php to your themes admin_template.php and editing it as required. Here is a copy of that function: Code: example
You can see an edited version of this function in the core theme Jayya's admin_template.php as an example. {ADMIN_MSG} {ADMIN_NAV} {ADMIN_PLUGINS} {ADMIN_PRESET} {ADMIN_PWORD} {ADMIN_SEL_LAN} {ADMIN_SITEINFO} {ADMIN_STATUS} Plugins are also able to register to display information in this menu, for example, the forum plugin registers with the menu to display the total number of forum posts. For details of how to enable your own plugin to display in this menu, please see the relevant page in the plugin coding section of this manual. There is an optional parameter with this shortcode which instructs it only to display when a page requests it. To use this feature, add the =request parameter to the shortcode in your admin_template.php like this: {ADMIN_STATUS=request} {ADMIN_USERLAN} {ADMIN_CREDITS} |
Shortcodes:ChatBoxThese shortcodes are used to style the ChatBox in the theme.php file of your theme. For more information goto Creating a theme from scratch: Chatbox Style. {USERNAME} {TIMEDATE} {MESSAGE} |
Shortcodes:CommentsThese shortcodes are used to style the Comments in the theme.php file of your theme. These shortcodes can be found in e107_files\shortcode\batch\comment_shortcodes.php . Contents [hide] {SUBJECT} {USERNAME} {REPLY} {AVATAR} {COMMENTS} {JOINED} {COMMENT} {COMMENTEDIT} {RATING} {IPADDRESS} {LEVEL} {LOCATION} {SIGNATURE} |
Shortcodes:ForumContents [hide] Forum Shortcodes {ANON_IP} {AVATAR} {CUSTOMTITLE} {EDITIMG} {EMAILIMG} {EMAILITEM} {JOINED} {LASTEDIT} {LATESTPOSTS} {LEVEL} {LOCATION} {MEMBERID} {MODOPTIONS} {POST} {POSTER} {POSTS} {PRINTITEM} {PRIVMESSAGE} {PROFILEIMG} {QUOTEIMG} {REPORTIMG} {RPG} {SIGNATURE} {THREADDATESTAMP} {THREADTOPIC} {TOP} {VISITS} {WEBSITE} {WEBSITEIMG} |
Shortcodes:FrontendThese shortcodes are those used in the public area of your site but they may also be used in the admin area in some circumstances. Contents [hide] {CUSTOM}
Important: As of 0.7.3, this shortcode is deprecated. Please use {SEARCH} and it's accompanying search_template instead. This is how to use it: {CUSTOM=search+default} {CUSTOM=search+".THEME."images/my_search.png} The default width and height of the image button is 16px x 16px. If your image uses different dimensions to these you can give the correct x and y coordinates like this: {CUSTOM=search+".THEME."images/my_search.png+30+12}
{CUSTOM=quote} Code: Example quote.txt {CUSTOM=login} {CUSTOM=clock} {CUSTOM=language} {LOGO} {MENU} {MENU=2} - Will render all menus assigned to area #2. {NEXTPREV}
{PLUGIN} {PLUGIN=chatbox_menu} - File is assumed to be e_PLUGIN/chatbox_menu/chatbox_menu.php {SEARCH} {SEARCH=news} - Search only news items. {SITECONTACTINFO} {SITELINKS} {SITELINKS_ALT} The presented links menu requires a mouse click on a parent to enable the dropdown. To make it auto expand on mouseover you need to use: {SITELINKS_ALT=no_icons+noclick} {SITENAME} {SITETAG} {SITEDISCLAIMER} {USER_AVATAR} {WMESSAGE} The welcome message display is also affected by the 'front page' options set for particular user classes. (It looks as if it usually only appears on the user's 'Home' page as set). There are several optional parameters: {WMESSAGE=header} {WMESSAGE=ignore_query} {WMESSAGE=force} {BANNER} {banner=ABCD} will only display banners from a campaign with name ABCD. {banner} will rotate through the banners in all campaigns. {E_IMAGE} {EMAIL_ITEM} Syntax message: sets the alt and the title attribute of the link Code: Result
{EMAILTO} Code: Example theme.php
{EXTENDED} - Deprecated {EXTENDED_ICON} EXAMPLE:
These both will show the icon of the extended field user_gender for user #5. {EXTENDED_TEXT} EXAMPLE:
These both will show the text of the extended field user_gender for user #5.
EXAMPLE:
These both will show the text of the extended field user_gender for user #5. {IMAGESELECTOR} Parameters
Would output: Code: Example Source
{LANGUAGELINKS} English | Français | 한국어 {LANGUAGELINKS=English,French,Korean} would render the first example above. define("LANGLINKS_SEPARATOR"," x ");
{LINKSTYLE} {NEWS_ALT} Code: Example {NEWS_CATEGORIES} {NEWS_CATEGORY} {NEWSFILE} Code: Example Code: Example Output
{NEWSIMAGE} Code: Example Code: Example Output {PICTURE} Code: Example {SETSTYLE} {SITEDISCLAIMER} {USER_EXTENDED} EXAMPLE:
{CONTACT_IMAGECODE} {CONTACT_IMAGECODE_INPUT} |
Shortcodes:NewsContents {NEWSTITLE} {NEWSBODY} {NEWSICON} {NEWSHEADER} Code: example {NEWSCATEGORY} {NEWSAUTHOR} Parameters {NEWSDATE} Parameters
{NEWSCOMMENTS} Code: example theme.php
If the news item has 2 comments it will output: Code: example comment(s): 2 You should use a language files for the COMMENTLINK constant, but I won't go into that. See this link for more information: Creating a theme from scratch: Language Information {NEWSCOMMENTLINK} {NEWSCOMMENTCOUNT} {EMAILICON} Override this icon by placing an email.png in your images/ folder of your theme. {PRINTICON} Override this icon by placing a print.png in your images/ folder of your theme. {PDFICON} {NEWSID} {ADMINOPTIONS} Override this icon by placing a newsedit.png in your images/ folder of your theme. {EXTENDED} Code: example theme.php
If news item_#3 has an extended post it will output: Code: example
You should use a language files for the PRE_EXTENDEDSTRING, EXTENDEDSTRING, and POST_EXTENDEDSTRING constants, or at least the EXTENDEDSTRING constant, but I won't go into that. See this link for more information: Creating a theme from scratch: Language Information Note: In 0.7.5 and earlier there was a potential conflict because the {EXTENDED} shortcode was also used in user-related fields. For 0.7.6 {USER_EXTENDED} has been defined, and {EXTENDED} applies only to news. {CAPTIONCLASS} Code: example output {ADMINCAPTION} {ADMINBODY} {NEWSSUMMARY} {NEWSTHUMBNAIL} {NEWSIMAGE} {STICKY_ICON} {NEWSTITLELINK} Parameters {NEWSCATICON} {TRACKBACK} Code: example theme.php
Code: Output {NEWSINFO} |
Shortcodes:UsersThese shortcodes are those used in user-related items of your site and can be found in the e107_files/shortcode/batch/user_shortcodes.php and e107_files/shortcode/batch/usersettings_shortcodes.php files. There are also some individual shortcodes. All fields display the data for the currently selected user. For user settings, the data is taken from the current form. Users User Settings Meaning/Usage INDIVIDUAL SHORTCODES {USER_EXTENDED} (from 0.7.6) USAGE: {USER_EXTENDED=<field_name>.[text|value|icon].<user_id>} EXAMPLE: {USER_EXTENDED=gender.value.5} will show the value of the extended field gender for user#5 Note: Within the database, all the field names are prefixed with 'user_'. However this is automatically added within the shortcode. If the user_id is zero, and the global variable $loop_id is defined, gets the extended fields for the user id specified by $loop_id. {EXTENDED} (deprecated) |
Contact form shortcodes |
User Journal shortcodes: |
Shortcodes:FormattingMany times you would like to add formatting around a shortcode only if the shortcode renders something. This is now possible with the $sc_style array. Example In your theme.php you would add something like: Code: theme.php snippet
When the shortcode engine renders the {AVATAR} shortcode, it will attach the 'pre' and 'post' strings to the return value only if it has some content (i.e. is not an empty string). Template Shortcoding Template Shortcoding Example In content_shortcodes.php you would add something like: Code: shortcode to return parent id
You should now be able to add formatting to {CONTENT_PARENT_ID} in your template. |
Shortcodes:Prerender Shortcode Pre-rendering shortcodes Some shortcodes can be pre-rendered in your theme.php or admin_template.php etc, so you can alter your themes output based on what is contained within your pre-renders. This is best illustrated with an example... In the admin area you will have noticed that after 30 days a menu appears that warns you that your password hasnt been updated and that you should now recreate it. This menu is rendered by the shortcode {ADMIN_PWORD} which is found in your admin_template.php. Perhaps you feel that the warning isnt strong enough and you want to display a big red warning message graphic above the menu when it is displayed. If you were to do the following code in your admin_template.php you will quickly notice a problem:
The problem is that your big red warning graphic will always show, even when the users password is not in need of being updated and the menu isnt being displayed. A way round this problem would be to pre-render the shortcode so you can test if its active and if so display your graphic and if not, dont display it. The first step then is to do the pre-render:
We do this before we define $ADMIN_HEADER. What has happened is that the shortcode has been processed early and the output from it, if there is any (ie. if the password needs updating and the menu is to be displayed), has been collated into the variable we created called $admin_password. If the menu isnt to be displayed, this variable wont contain any data - ie. it will be an empty string: "". Now we know this information we can create a rule when building our $ADMIN_HEADER to determine if the $admin_password variable contains the menu or an empty string and if it does we display our big red warning graphic, if it doesnt we dont display the graphic. Here's the code:
Obviously, you need to know PHP to take full advantage of pre-rendering, but this additional feature will allow you to create truly dynamic themes. |
Shortcodes:Themes Contents Adding or overriding shortcodes with your theme Code: Line to add to top of theme.php file For instance, you probably can include {XXXX} within $HEADER since $HEADER is parsed. You could NOT include it within theme as Code: This won't work without parsing Example: Create a shortcode to style individual menus Create the testshortcode.sc file Code: testshortcode.sc
Modify your theme.php file Code: Put at the top of your theme Code: Put inside function tablestyle($caption, $text, $mode){...}
What you should see
when you visit your forum.php page, and
above your left menu. Just for giggles, try using {TESTSHORTCODE} in other parts of your theme with and without the parsing statements to see what happens. Mighty and armed, you're now ready to Style your individual menus. |
Shortcodes:Override Plugin ShortcodesContents Warning Scope Why Override? The Hack
You then create your_shortcode_file.php with the name of the existing shortcode if you want to override or the name of a new shortcode. Example from Content Management
I also created a "KMD_shortcodes.php" file in my theme directory which looks something like:
And that is pretty much it. Troubleshooting
e107 developers: I'm begging you... Use Shortcodes and Templates Enable Formatting
That way we can format them as in Shortcodes:Formatting. Again, lisa has done a great job with this in Content Management. Enable shortcode overriding/extending Allow shortcodes to be added to all template variables Sorry for the rant. |
Shortcodes, adding to the forumContents Adding Shortcodes to the Forum The following is an extract from a forum post which give an idea of modifying the layout of a forum thread: You will need to identify the correct template file to edit - the defaults are in e107_plugins/forum/templates; however some themes override them with alternative files of the same names, in which case they will be in the theme directory. Probably forum_viewforum_template.php will be what you want. Look at this in a text editor (even Notepad will do), and you should be able to see the correspondence with your forum layout. At line 89 in the default file is a line starting: $FORUMTHREADSTYLE = .... the text which follows sets the format of each post. It is a mix of HTML and shortcodes, so you do need to at least understand a bit of HTML. A little way down you will see: this is displaying information from the extended user fields - location.text is the 'description', and location.value is the actual value. You can add fields in a similar format to pull out your other extended user fields. Adding a custom picture to the forum Creating the shortcode Put the following code into that page
Once you have prepared this file, and the associated graphics, proceed as follows: Upload this file to e107_files/shortcode/ The images work in the forum now, if you want them to show in the profiles continue: Go to the top of the page
this way the layout of your profile is not messed up. Further explanation the e107 developers (highest rank within the classes) the e107 moderators (2nd rank within classes) the e107 support team (3rd rank within classes) If someone belongs to more than 1 group (eg 2dopey is both support and moderator), we want the picture for the highest rank within the classes to be showed. In the forums we want a picture of a moderator for 2dopey, not support as this is of a lower rank. I used the ranks to make the distinction as to what should be showed. If a developer is also a moderator, we want the picture of developer to show, not a moderator. Therefore a ranking of these classes is made within this script. |
Shortcodes, adding to a plugin As of e107 v0.7.6 there are two ways to add shortcodes to your plugin: 1. adding any file in your plugin folder with the extension .sc You will then just need to include a newcode.sc file in your main plugin directory. See e107_files/shortcodes for sample files. Whenever {NEWCODE} is found, it will be replaced with the code returned from your newcode.sc 2. adding an e_sc.php file in your plugin folder. (to be continued) Note: To be sure that your shortcode is registered in e107, check the Preference Viewer in admin -> database and look for your file in the pref called shortcode_list. |
Shortcodes guide
The text was updated successfully, but these errors were encountered: