Bài đăng

Đang hiển thị bài đăng từ tháng 12 16, 2007

Module Hello World 3

Introduction This tutorial aims to further build on the helloworld module we expanded in part three. You will learn how to use parameters to fine tune some of the information that is displayed. We will also look at looking at ways to 'skin' your module output.. Requirements You need for this tutorial: • Joomla 1.0 or greater Let's Roll You will recall that we finished part 2 with your module displaying a list of the most hit times. Unfortunately we were stuck with displaying only 5 items and could not change the ordering. What we will do in this example is learn how to add parameters to the module so that you can vary these conditions. Setting up the Parameters We need to revisit the XML file that we created in part 1. We define all our parameters in this file. First let's consider what variables we want to allow the user to change: 1. We want a variable to change the number of items displayed. 2. We want to be able to select the ordering of the items from a list.

Module Hello World 2

Introduction This tutorial aims to build on the helloworld module started in part one. You will learn how to retrieve information from the database and how to present this data is a table using patTemplate. Requirements You need for this tutorial: • Joomla 1.0 or greater Let's Roll You will recall that we finished part 1 with your module displaying a message and the current time. This is all very interesting but far more interesting is the information held in the tables of the Joomla database. What we will do in this example is develop a type of Current News module. The Presentation Layer Let's start with the output of the module. Because the code (or the logic) of the module is now separated from the presentation layer (the HTML), it gives the graphic designer an opportunity to design the output separate from the module. The module code designer has informed us that a list of content items will be provided to the template. The content item data will include the item id, t

Module Hello World 1

Introduction This tutorial aims to give you a grounding in the basic concepts for writing Joomla! modules. It will develop a very simple Hello World module and then extend it using patTemplate, a powerful set of functions that help separate the presentation (HTML) from the application logic (PHP) using templates. Full documentation for patTemplate can be found on their website. Requirements You need for this tutorial: • Joomla! 1.0 or greater Let's Roll We will be creating two files in this tutorial in the folder called /modules/. Let's look at the files we need. mod_helloworld.php This file is the actually engine for the module. mod_helloword.xml This file is the XML setup file for the module. It defines the information required for the module to be installed. Installing the Basic Module You cannot create a module from scratch from the Joomla! Administrator, so we have to make some basic files first and then install them as a module. Let's make the actual module first. Sav

Writing a Simple Module in joomla

As an example, we will create a module that will list any content items that have keywords that match those in the one that is being viewed. Where do we start? First decide on a module name. We are going to call this a Related Items module. The module name will be mod_relcontent. All module names must be prefixed with "mod_" and the "relcontent" just stands for "related content" in our case. In a scratch area on your file system, create a directory called mod_relcontent. In this directory, just create two empty files for the moment; one called mod_relcontent.php and the other called mod_relcontent.xml. Let's build the XML file first. This is a definition file that tells the Joomla installer, most importantly, what files are required and other metadata about the module. [Please ignore this dummy sentence which is intended to deflect the glossary bot from incorrectly autocapitalising the word "{glossarbot=disable}author" in the XML sample belo

bảng quảng cáo hay một bảng thông tin tự động trượt đến một vị trí được chỉ định

Thỉnh thoảng có lúc bạn muốn có một bảng quảng cáo hay một bảng thông tin tự động trượt đến một vị trí được chỉ định khi visitor scroll trang web lên-xuống. Đây là cách rất tốt để ưu ái quảng cáo của những đối tượng sẵn sàng chí trả nhiều tiền. Cách làm như sau: Mở file index.php của template bạn đang sử dụng bằng bất kỳ trình soạn thảo văn bản nào và... 1. Ngay trước thẻ &lt/head> thêm đoạn code sau: Code: &lt!-- Floating Object container \--> &ltscript type="text/javascript"> var isDOM, floaterObj; var isNS, pageHeight; var paddingX, paddingY, scrollTop, currentY, targetY, A, B, C, D; var slideTime; /* h - height in pixel of the floating object x - padding in pixel from the left side of floating object to the left side of browser window y - padding in pixel from the top side of floating object to the top side of browser window z - slide time in milisecond */ function setUp(h, x, y, z) { if (document.getElementById) { isDOM = true; floaterObj =

modify mod_latestnew & mod_mostread to show the image

&lt?php // no direct access defined( '_VALID_MOS' ) or die( 'Restricted access' ); global $mosConfig_offset, $mosConfig_live_site, $mainframe; $type = intval( $params->get( 'type', 1 ) ); $count = intval( $params->get( 'count', 5 ) ); $catid = trim( $params->get( 'catid' ) ); $secid = trim( $params->get( 'secid' ) ); $show_front = $params->get( 'show_front', 1 ); $now = date( 'Y-m-d H:i:s', time() ); $access = !$mainframe->getCfg( 'shownoauth' ); $nullDate = $database->getNullDate(); // select between Content Items, Static Content or both switch ( $type ) { case 2: //Static Content only $query = "SELECT distinct a.id, a.title, a.images" . "\n FROM #__content AS a" . "\n WHERE ( a.state = 1 AND a.sectionid = 0 )" . "\n AND ( a.publish_up = '$nullDate' OR a.publish_up &lt= '$now

Cross-window scripting

var newwindow = ''; function popitup(url) { if (!newwindow.closed && newwindow.location) { newwindow.location.href = url; } else { newwindow=window.open(url,'name','height=200,width=150'); if (!newwindow.opener) newwindow.opener = self; } if (window.focus) {newwindow.focus()} return false; }

thay đổi code trong module latest_news.

$secid = trim( $params->get( 'secid' ) ); thêm đoạn code này vào để lấy $secid global $option, $task; if ($option == 'com_content') { switch($task) { case 'view': $query = "SELECT a.sectionid" . "\n FROM #__content AS a" . "\n WHERE ( a.id = ".$_GET['id']." )"; $database->setQuery( $query, 0, $count ); $rows = $database->loadObjectList(); $sectionrow = $rows[0]; $secid = $sectionrow->sectionid; break; case 'section'; $secid = $_REQUEST['id']; } } Như thế là ta đã có section id khi đó mọi việc trở nên đơn giản. Chỉ cần chỉnh câu lệnh SQL để lấy a.sectionid = $secid là xong.

A Better Ajax Back Button Solution

If you've spent any time coding an Ajax application you know that the one of the problems with Ajax is that it breaks the back button. You have probably seen solutions that use an iframe and a hash (#) in the url to fix this issue. While this works there is a much simpler way that I've been using in my applications for the last year or so. The key is the A tag (also known as the anchor tag) and the name parameter with a hash in the url. The trick is to either dynamically create the element or to just change the value of the name parameter to the matching value of the hash. Below is an example of changing the name of the anchor tag. //Anchor Rename Object this could also be a simple function if preferred. var AnchorRename=new Object(); AnchorRename.CreateObject=function(anchorname, anchorid){ this.anchorid=anchorid; //This is the id of the anchor element this.anchorname=anchorname; this.RenameAnchor(anchorname, anchorholerid); }; AnchorRename.C

simple sample code that shows how you can persist state into a hidden form

<html> <head> <script language="JavaScript"> function initialize() { var sessionField = document.getElementById("sessionField"); var sessionValue = sessionField.value; if (sessionValue == "empty") { alert("Storing new session value"); sessionField.value = "Hello World"; } else { alert("Old session value: " + sessionValue); } } </script> </head> <body onload="initialize()"> <form id="sessionForm"> <textarea id="sessionField">empty</textarea> </form> </body> </html>

AJAX Tutorial: Saving Session Across Page Loads Without Cookies, On The Client Side

<html> <head> <script language="JavaScript"> function initialize() { if (sessionExists() == false) { saveState("Hello World 1"); // some browsers need a bit of a timeout window.setTimeout("saveState('Hello World 2')", 300); window.setTimeout("saveState('Hello World 3')", 600); } } function getIFrameDocument() { var historyFrame = document.getElementById("historyFrame"); var doc = historyFrame.contentDocument; if (doc == undefined) // Internet Explorer doc = historyFrame.contentWindow.document; return doc; } function sessionExists() { var doc = getIFrameDocument(); try { if (doc.body.innerHTML == "") return false; else return true; } catch (exp) { // sometimes an exception is thrown if a // value is already in the iframe return true; } } function saveState(

Dưới đây là bảng danh sách phím tắt chủ yếu dùng cho cả hai trình duyệt IE và Firefox

Dưới đây là bảng danh sách phím tắt chủ yếu dùng cho cả hai trình duyệt IE và Firefox ( Trên Macintosh, Command thay thế cho Ctrl và tuỳ chọn cho Alt ) Các phím tắt thông thường sử dụng cho cả Firefox và Internet Explorer Phím tổ hợp Cách dùng Ctrl+A Chọn tất cả nội dung Ctrl+C Copy nội dung chọn Ctrl+D Thêm một bookmark Ctrl+H Thể hiện thanh nách History Ctrl+I hay Ctrl+B Mở thanh nách Bookmarks C

Disable right click script and no alert

// JavaScript Document <script type="text/javascript" language="JavaScript1.2"> /**Start hiding from IE Mac */ <!-- // Begin //Disable right click script and no alert var message=""; /////////////////////////////////// function clickIE() {if (document.all) {(message);return false;}} function clickNS(e) { if (document.layers||(document.getElementById&&!document.all)) { if (e.which==2||e.which==3) {(message);return false;} } } if (document.layers){document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;} else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;} document.oncontextmenu=new Function("return false") // End --> /**Stop hiding from IE Mac */ </script> insert this script in &lthead>

xajax dhtmlHistory-Extension (Bookmark and Backbutton)

Based on Brad Neuberg's "Really Simple History". See: <a href="http://code.google.com/p/reallysimplehistory/" target="new">his page</a> for details This plugin makes it possible to handle the browsers backbutton functionality and provides a simple bookmarking management. It works with IE and FF and with the new RSH Version also with Opera and even Safari. <h2>xajax 0.5 Beta4 - Really Simple History 0.6</h2><b>Last changed: 2007-12-03</b> The package contains the following files: <table border="1"> <tbody><tr><th>file</th><th>folder</th><th>comment</th></tr> <tr><td colspan="3"><b>plugin files</b></td></tr> <tr><td>dhtmlHistory.inc.php</td><td>./xajax/xajax_plugins/response</td><td>the xajax plugin</td></tr> <tr><td>rsh.compr

show the message & hide the message

Hình ảnh
Often, we want to notify the end user that an operation is in process; to let them know they may need to wait a bit for the operation to finish. First, let's define the message, what to do to show the message and what to do to hide the message: and later (in the HTML of the page): Loading, please wait a moment... ---------- With xajax 0.2.4 (the current release), you can accomplish this with the following javascript code: ---------- With xajax 0.5 (the current beta release), you can accomplish this with the following javascript code: on a global level: on a per call basis: Indeed, same question. Would it be loaded by onLoad? We need a bit more information on this one. I have a very simple .js called under my body tag, which uses a YUI Panel to display an Ajax loader icon (created with www.ajaxload.info), but I'd like to increase the delay time to about 500 milli or even one full second. Some of the database calls are slow and my users click several times sometimes, which make m

Using xajax 0.5 beta 2, you can now use the following (callback objects)

Using xajax 0.5 beta 2, you can now use the following (callback objects) to accomplish this: loadingPage = xajax.callback.create(300, 10000); loadingSomeSelectOptions = xajax.callback.create(300, 10000); loadingOtherSelectOptions = xajax.callback.create(100, 10000); Then, provide the operations to perform: loadingPage.onResponseDelay = function() { ... show loading message ... } loadingPage.onComplete = function() { ... hide loading message ... } loadingSomeSelectOptions.onRequest = function() { ... show loading message over select box ... } loadingSomeSelectOptions.onComplete = function() { ... hide loading message ... } loadingOtherSelectOptions.onResponseDelay = function() { ... show loading msg over other select box ... } loadingOtherSelectOptions.onComplete = function() { ... hide loading message ... } Then: xajax.call('loadPage', { callback: loadingPage }); xajax.call('loadSomeSelectOptions', { callback: loadingSomeSelectOptions }); etc... As an alternative, you c