Free Joomla Listing | Joomla Extensions Directory Showcase | Component, Module, Plugin, Templates Free Joomla Extensions Directory Listing Services: Component,Modules,Plugin,Templates. Our Site Showcase provides Tutorials, Tips Trick Joomla Development for building a website with CMS open source joomla. http://www.joomlapublisher.com/feed/atom.html 2012-05-17T17:06:43Z Joomla! 1.5 - Open Source Content Management Joomla Resource, Tutorials and News for Joomla 2010-05-16T12:53:52Z 2010-05-16T12:53:52Z http://www.joomlapublisher.com/103-joomla-resource-tutorials-and-news-for-joomla.html Administrator cs@balipublisher.com <img alt="joomla" src="http://www.joomlapublisher.com/images/stories/joomla.jpg" height="266" width="400" /> <img alt="joomla" src="http://www.joomlapublisher.com/images/stories/joomla.jpg" height="266" width="400" /> Recover Joomla Error Page with Redirect Joomla! 1.6 Component 2011-03-24T20:31:54Z 2011-03-24T20:31:54Z http://www.joomlapublisher.com/107-recover-joomla-error-page-with-redirect-joomla-16-component.html Administrator cs@balipublisher.com <p><img class="caption" alt="16_redirect_plugin_list" src="http://www.joomlapublisher.com/images/stories/16_redirect_plugin_list.jpg" width="789" height="356" /></p> <p>A new component and plugin called Redirect has been icluded at <em><strong><a title="joomla 1.6" href="http://www.joomlapublisher.com/index.php?option=com_content&view=article&id=101:upgraded-joomla-update-release&catid=34&Itemid=100">Joomla 1.6 release</a></strong></em>.&nbsp; Its main function is to provide a mechanism to record 404 "not found" errors, and to give the Web site owner the ability to redirect those to another page if desired.</p> <p>The Redirect component and plugin is very important in Joomla 1.6 because, at the very least, the new category system will create some new URL's.&nbsp; Some Joomla 1.5-style URL's will no longer be applicable in Joomla 1.6.&nbsp; However, Joomla 1.6's new capabilities may also lead you to experiment with new site structure that was not achievable in Joomla 1.5.&nbsp; Whatever the case, Redirect has been provided to give you the best chance of preserving your search engine page rank (amongst other things).</p> <p><img class="caption" alt="16_redirect_plugin_list" src="http://www.joomlapublisher.com/images/stories/16_redirect_plugin_list.jpg" width="789" height="356" /></p> <p>A new component and plugin called Redirect has been icluded at <em><strong><a title="joomla 1.6" href="http://www.joomlapublisher.com/index.php?option=com_content&view=article&id=101:upgraded-joomla-update-release&catid=34&Itemid=100">Joomla 1.6 release</a></strong></em>.&nbsp; Its main function is to provide a mechanism to record 404 "not found" errors, and to give the Web site owner the ability to redirect those to another page if desired.</p> <p>The Redirect component and plugin is very important in Joomla 1.6 because, at the very least, the new category system will create some new URL's.&nbsp; Some Joomla 1.5-style URL's will no longer be applicable in Joomla 1.6.&nbsp; However, Joomla 1.6's new capabilities may also lead you to experiment with new site structure that was not achievable in Joomla 1.5.&nbsp; Whatever the case, Redirect has been provided to give you the best chance of preserving your search engine page rank (amongst other things).</p> Strelin CMS – a fork of Joomla 1.5 2011-03-18T15:01:32Z 2011-03-18T15:01:32Z http://www.joomlapublisher.com/106-strelin-cms-a-fork-of-joomla-15.html Administrator cs@balipublisher.com <p>Strelin CMS is a new fork of the popular open source content management system, Joomla!. Forked from version 1.5, this new CMS is described as having an advanced ACL that Joomla! currently is lacking. Strelin is an open source project released under the GNU/GPL license and is made available for free to anyone wishing to use it for personal or commercial websites. You can download a free copy now!</p> <p>Strelin CMS is a new fork of the popular open source content management system, Joomla!. Forked from version 1.5, this new CMS is described as having an advanced ACL that Joomla! currently is lacking. Strelin is an open source project released under the GNU/GPL license and is made available for free to anyone wishing to use it for personal or commercial websites. You can download a free copy now!</p> The Predictions for Web CMS in 2011 2011-03-18T14:50:03Z 2011-03-18T14:50:03Z http://www.joomlapublisher.com/105-the-predictions-for-web-cms-in-2011.html Administrator cs@balipublisher.com <p>The website of the future will be a seamless blend of corporate generated and user generated content. Social is no longer just a disconnected feature of a website, it’s a fundamental shift in how companies embrace customer relationships, transparency, and authenticity. In 2011, we’ll finally start to see companies and brands adopt the principals outlined by Jeremiah Owyang in his 2007 blog how on How to Evolve Your Irrelevant Corporate Website</p> <p>Corporate websites took a giant leap forward, evolving from static to dynamic, and from generic to personal. The explosive growth of mobile devices in new form factors like the iPad caused CMOs to rethink their mobile strategies.</p> <p>The website of the future will be a seamless blend of corporate generated and user generated content. Social is no longer just a disconnected feature of a website, it’s a fundamental shift in how companies embrace customer relationships, transparency, and authenticity. In 2011, we’ll finally start to see companies and brands adopt the principals outlined by Jeremiah Owyang in his 2007 blog how on How to Evolve Your Irrelevant Corporate Website</p> <p>Corporate websites took a giant leap forward, evolving from static to dynamic, and from generic to personal. The explosive growth of mobile devices in new form factors like the iPad caused CMOs to rethink their mobile strategies.</p> Ready to Download, Joomla 1.6 Beta Now Available 2010-05-21T21:32:16Z 2010-05-21T21:32:16Z http://www.joomlapublisher.com/104-ready-to-download-joomla-16-beta-now-available.html Administrator cs@balipublisher.com <img style="float: left;" class="caption" alt="joomla 1.6" src="http://www.joomlapublisher.com/images/stories/beta_logo.png" height="157" width="157" />The Joomla Project, a free, award-winning PHP-based content management system that enables users to build websites and powerful online applications, today announced the beta release of Joomla 1.6. Designed to offer enhanced site control and a more polished user experience, Joomla 1.6 will deliver a variety of new tools to improve website management and access, a more robust organizational structure for content control, and various other user-experience improvements throughout the software. <img style="float: left;" class="caption" alt="joomla 1.6" src="http://www.joomlapublisher.com/images/stories/beta_logo.png" height="157" width="157" />The Joomla Project, a free, award-winning PHP-based content management system that enables users to build websites and powerful online applications, today announced the beta release of Joomla 1.6. Designed to offer enhanced site control and a more polished user experience, Joomla 1.6 will deliver a variety of new tools to improve website management and access, a more robust organizational structure for content control, and various other user-experience improvements throughout the software. It’s time to mobilize your Joomla Site 2010-05-16T12:04:20Z 2010-05-16T12:04:20Z http://www.joomlapublisher.com/102-its-time-to-mobilize-your-joomla-site.html Administrator cs@balipublisher.com <img style="float: left;" class="caption" alt="mobile joomla" src="http://www.joomlapublisher.com/images/stories/mobilejoomla.jpg" height="255" width="298" />Today’s Mobile communications have become a key component  marketing scene, millions of people are now surfing the web on their cell phones so .. don’t be left out. It’s time to enhance your<a title="Joomla publishing " href="http://www.bloggermatre.com"> <span style="color: #000000;">joomla site</span></a><span style="color: #000000;"> </span>to market to the ever-growing numbers of mobile users. By introduce your product and services for users mobile  access into your marketing mix by extending current promotions with mobile-only offers. <img style="float: left;" class="caption" alt="mobile joomla" src="http://www.joomlapublisher.com/images/stories/mobilejoomla.jpg" height="255" width="298" />Today’s Mobile communications have become a key component  marketing scene, millions of people are now surfing the web on their cell phones so .. don’t be left out. It’s time to enhance your<a title="Joomla publishing " href="http://www.bloggermatre.com"> <span style="color: #000000;">joomla site</span></a><span style="color: #000000;"> </span>to market to the ever-growing numbers of mobile users. By introduce your product and services for users mobile  access into your marketing mix by extending current promotions with mobile-only offers. Joomla!® 1.6.0 is now available for download 2010-05-16T11:50:22Z 2010-05-16T11:50:22Z http://www.joomlapublisher.com/101-upgraded-joomla-update-release.html Administrator cs@balipublisher.com <img style="float: left;" class="caption" alt="Joomla 1.60" src="http://www.joomlapublisher.com/images/stories/200x200.jpg" height="200" width="200" />The Joomla Project announces the immediate availability of Joomla 1.6.&nbsp; This new version of Joomla includes more power, more control, and more options than ever before. With Joomla 1.6 developers will build extensions faster through all phases of design, deployment and updates. Advanced and rich API’s will provide new opportunities to integrate, compete and expand into existing and new markets.<br /><br />Rebuilt from the ground up in much of the application, this latest Joomla release will delight the casual site builder while helping small, medium, and enterprise businesses succeed in delivering web sites, intranets and applications to their respective markets. <img style="float: left;" class="caption" alt="Joomla 1.60" src="http://www.joomlapublisher.com/images/stories/200x200.jpg" height="200" width="200" />The Joomla Project announces the immediate availability of Joomla 1.6.&nbsp; This new version of Joomla includes more power, more control, and more options than ever before. With Joomla 1.6 developers will build extensions faster through all phases of design, deployment and updates. Advanced and rich API’s will provide new opportunities to integrate, compete and expand into existing and new markets.<br /><br />Rebuilt from the ground up in much of the application, this latest Joomla release will delight the casual site builder while helping small, medium, and enterprise businesses succeed in delivering web sites, intranets and applications to their respective markets. Tutorial Debugging JavaScript with Firebug 2009-12-24T16:20:17Z 2009-12-24T16:20:17Z http://www.joomlapublisher.com/96-video-tutorial-debugging-javascript-with-firebug.html Administrator cs@balipublisher.com <p><img class="caption" src="http://l.yimg.com/a/i/us/sch/cn/v/v0/w327/111597_320_240.jpeg" alt=" Firebug" align="left" /></p> <p>If you're working with JavaScript in the browser, it won't be very long before you need to debug your code to fix error in your <a title="web blog resources" href="http://www.bloggermatre.com">web blog contents</a>. In this first video, Joel Hewitt, creator of the essential <span style="text-decoration: underline;"><strong><a href="http://getfirebug.com/" rel="nofollow">Firebug</a></strong></span> plugin for Firefox, introduces Firebug and teaches you how to use it. (Note: This video is for Firebug 1.0, but the current version of Firebug is 1.4. Despite the version difference, the video still provides a great overvidew of the tool.)</p> <p> </p> <p><img class="caption" src="http://l.yimg.com/a/i/us/sch/cn/v/v0/w327/111597_320_240.jpeg" alt=" Firebug" align="left" /></p> <p>If you're working with JavaScript in the browser, it won't be very long before you need to debug your code to fix error in your <a title="web blog resources" href="http://www.bloggermatre.com">web blog contents</a>. In this first video, Joel Hewitt, creator of the essential <span style="text-decoration: underline;"><strong><a href="http://getfirebug.com/" rel="nofollow">Firebug</a></strong></span> plugin for Firefox, introduces Firebug and teaches you how to use it. (Note: This video is for Firebug 1.0, but the current version of Firebug is 1.4. Despite the version difference, the video still provides a great overvidew of the tool.)</p> <p> </p> Create Image Caption with Mootool 2009-09-27T12:49:10Z 2009-09-27T12:49:10Z http://www.joomlapublisher.com/77-create-image-caption-with-mootool.html Administrator cs@balipublisher.com <p>Using MooTools will allow you to write auto caption images on-the-fly using a bit of MooTools magic. MooTools is a powerful open-source JavaScript framework that can greatly enhance the way you build your web interfaces. The first thing we want to do is mark up our images</p> <p><strong>HTML</strong></p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">&lt;img class="captioned" src="http://www.joomlapublisher.com//red_rocks.jpg"<br />title="Photo of Red Rock Mountain." width="300" height="201" /&gt;</p> <p><strong>CSS</strong></p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">img {<br />padding:5px 0;<br />}<br />div.figure {<br />width:310px;<br />text-align:center;<br />border:1px solid #ccc;<br />background-color:#f2f2f2;<br />margin:5px;<br />float:left;<br />}<br />p.caption {<br />padding:0;<br />margin:0 0 5px 0;<br />font:italic 12px Georgia, "Times New Roman", Times, serif;<br />color:#333333;<br />}</p> <p>div.figure will be the container of our image and caption. p.caption will be our actual caption. We’re going to use MooTools to insert these two things in our Document Object Model (DOM).</p> <p><strong>The code logic: manipulating the DOM</strong></p> <p>Before we get into any code-authoring, let’s step through the logic of what we’re trying to accomplish.</p> <p>First, we’re going to select all of the images in our structure that has a class ofcaptioned. Then for each image that matches our criteria, we’re going to:</p> <ol style="margin: 10px 0px 15px 50px; padding: 0px"> <li>Determine whether it has an alt or title attribute.</li> <li>If it has neither an alt or title attribute, we don’t do anything to the image and warn the user that the image needs at least one for our script to work.</li> <li>If we find both a alt and title attribute, then we will use the title attribute value for our caption.</li> </ol> <p>Once we get the text for our caption, we will create a new DOM element, a paragraph element (&lt;p&gt;) called caption which will contain our caption text.</p> <p>Once caption is created, we’ll create another DOM element (a div) to contain our image and caption. We will call this new DOM element figure.</p> <p>Through DOM manipulation, we’re going to end up with an HTML structure like this:</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">&lt;div class="figure"&gt;<br /> &lt;img class="captioned" src="http://www.joomlapublisher.com//red_rocks.jpg"<br /> title="Photo of Red Rock Mountain." width="300" height="201" /&gt;<br /> &lt;p class="caption"&gt;Photo of Red Rock Mountain.&lt;/p&gt;<br />&lt;/div&gt;</p> <p>Of course, this will happen behind the scenes, but that’s basically what our HTML will look like after our MooTools script runs.</p> <p><strong>Initializing MooTools</strong></p> <p>Now that we have our HTML and CSS set up and we have a rough overview of what we’re going to do - we’re ready to start scripting!</p> <p>First, we’ll initialize MooTools by wrapping all of our code inside the ‘domready’ event listener.</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">window.addEvent('domready', function() {<br /> ... Our code goes in here ...<br />});</p> <p style="padding: 0px">What this method does is it tells MooTools that as soon as the DOM is ready, we’ll run our code. This way, we’re not waiting for the page to load before we execute our JavaScript.</p> <p><strong>Selecting and iterating through our images</strong></p> <p>We’ll select our images to be captioned by using the $$() function which is often called the "dollars" function. $$() is very intuitive and works almost exactly like CSS selectors. To select all images that have the class captioned, we write:</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">$$('img.captioned')</p> <p>Tip: we can also just use $$('.captioned') assuming that you only use this class for images. To be safe - I’ve chosen to increase the specificity of our selector.</p> <p>Next,we will iterate through each image that matches our criteria using the .each()method.</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">window.addEvent('domready', function() {<br /> $$('img.captioned').each(function(el) {<br /> ...Everything we write will go in here...<br /> });<br />});</p> <p><strong>Getting the text for our caption</strong></p> <p>We’re going to use the getProperty() method to pull out the title attribute value.</p> <p>We’ll put this value inside a string variable called captionText.</p> <p>To get the value, we write:</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">var captionText = el.getProperty('title')</p> <p>In our HTML markup, the value of captionText should now be:</p> <p>"Photo of Red Rock Mountain."</p> <p>But we have to consider the situation that the image might have both an alt and atitle property declared.</p> <p>So, we’re going to use a ternary control structure to check if there’s a title and if we find it, then we’ll use that for our caption; if not, we’ll try to see if there’s an altproperty and use that instead. If they both don’t exist, then captionText gets assigned a null value.</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">var captionText = ( el.getProperty('title')!=null )<br /> ? el.getProperty('title') : el.getProperty('alt');</p> <p>Note: ternary operators are just shorthand for if statements. You can easily convert the above code into nested if statements and it will work just fine. Have a go at it, convert this bit to an if structure. If you need help ask in the comments.</p> <p>In plain english, this all translates to "If the current object’s title attribute value is not null, then captionText will take on that value; otherwise, captionText will take on the value of the alt attribute."</p> <p>Explore: Here’s a good spot to explore by yourself. Try to modify our ternary operator so that the alt attribute takes precedence over the title attribute.</p> <p><strong>Making sure we have a caption</strong></p> <p>Before we do anything else, we have to make sure that our object will have a caption.</p> <p>So we make sure the captionText doesn’t contain a null value. We’ll do this with a basic if control structure</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">if ( captionText!=null ) {<br /> //code to execute if we have a caption<br />} else {<br /> //code to execute if we encounter an error (Error-handling code goes here).<br />}</p> <p><strong>Error-handling</strong></p> <p style="padding: 0px">Let’s jump ahead to our error-handling and reporting. The method we’ll use is very rudimentary: if we find that the current object doesn’t have a caption (i.e.captionText != null evaluates to false), then we’re going to tell the user that this image needs either a title or an alt attribute.</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">alert('The image: "'+el.getProperty('src')+'" needs a title or alt value.');</p> <p>To help identify the image, we take the src value, which outputs the location of our image.</p> <p>IMPORTANT: This type of error-handling and reporting isn’t good practice; we used this in the example to make things easier on ourselves. But in production, you would want to replace this code with a better way to handle errors.</p> <p><strong>Messing around with the DOM</strong></p> <p>Now, we’re going to get into the thick of things – DOM manipulation. We’re going to insert two new elements in our Document Object Model; they are figure andcaption.</p> <p>The first element we’re going to make is the figure element. This element will be adiv element that will contain our image and our other new element (caption).</p> <p><strong>Declaring our figure prototype</strong></p> <p>In order to create a new element in MooTools, we use the following structure:</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">var elementName = new Element('type of element', {its  properties})</p> <p>We want figure to be a div with a class of figure and 10 pixels wider than our image (so that we have a 5-pixel margin on the left and the right).</p> <p>Our prototype for figure then becomes:</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">var figure = new Element('div', {<br /> 'class' : 'figure',<br /> 'styles' : {<br /> 'width' : el.get('width').toInt() + 10<br /> }<br />});</p> <p>To get the width, we use the get() method, and then we convert the value to an integer with the .toInt() method. We then add 10 pixels (+ 10) to the width so that we get the 5-pixel margin on either sides of the image.</p> <p>Are you with me so far? Keep up, we’re almost there!</p> <p><strong>Declaring our caption prototype</strong></p> <p>So we just built our first new element, figure. Now we have to build our second element, caption. caption will be a paragraph element (&lt;p&gt;) and will contain the caption’s text we took from our image (remember: it’s inside captionText).</p> <p>Let’s get right to it, here’s our caption element prototype:</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">var caption = new Element('p', {<br /> 'class' : 'caption',<br /> 'html' : captionText<br />});</p> <p>Review: Go to the MooTools Doc entry on the Element method: constructor to learn more about creating new elements.</p> <p>In the above construction, we created a new element called caption. We told MooTools that we want it to be a paragraph (&lt;p&gt;) element that has a class ofcaption and the HTML that should be inside it is equal to captionText.</p> <p><strong>Manipulating the DOM</strong></p> <p><strong>Wrapping our object inside figure</strong></p> <p>The first DOM manipulation that we’ll pull off is wrapping our object inside ourfigureelement. We’ll use the wraps() method which (as the name implies) wraps the target object of the method with the argument you pass into it.</p> <p>with this in mind, all we have to do is write:</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">figure.wraps(el);</p> <p><strong>Inserting caption into the DOM</strong></p> <p>After that, we want to insert caption after our image. We’ll use the inject() method for this.</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">caption.inject(el,'after');</p> <p><strong>Summing up</strong></p> <p>Let’s bring everything together in one big chunk. Here’s the entire MooTools script.</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">window.addEvent('domready', function() {<br /> $$('img.captioned').each(function(el) {<br /> var captionText = ( el.getProperty('title')!=null )<br /> ? el.getProperty('title') : el.getProperty('alt');<br /> if ( captionText!=null ) {<br /> var figure = new Element('div', {<br /> 'class' : 'figure',<br /> 'styles' : {<br /> 'width' : el.get('width').toInt() + 10<br /> }<br /> });<br /> var caption = new Element('p', {<br /> 'class' : 'caption',<br /> 'html' : captionText<br /> });<br /> figure.wraps(el);<br /> caption.inject(el,'after');<br /> } else {<br /> alert('The image: "'+el.getProperty('src')+'" needs a title or alt value.');<br /> }<br /> });<br />});</p> <p><strong>What did we just do?</strong></p> <p>In this tutorial, we used the MooTools JavaScript framework to automatically display captions below images that have the class of captioned. We did this by selecting all the elements that matched our criteria, iterated through the matched set, and for each object in the matched set, we:</p> <ol style="margin: 10px 0px 15px 50px; padding: 0px"> <li>Determined our caption’s text by getting the value of the object’s titleattribute, and if it didn’t have one, then we defaulted to its alt attribute.</li> <li>Constructed the figure element that wraps around our image and caption.</li> <li>Constructed the caption element, a paragraph that has our image’s caption.</li> <li>Wrapped our image inside the figure element using the wraps() method.</li> <li>Injected caption right after our image using the inject() method.</li> </ol> <p>We also made a very basic error-handling system that warns the user via an alert message that a title or alt value is required.</p> <p><strong>Review questions for beginners</strong></p> <p style="padding: 0px">This script is far from perfect. I chose to leave it that way to encourage you to explore MooTools and analyze the code we wrote together.</p> <p style="padding: 0px">Here are some questions to try and answer yourself. I will post the answer in the comments section at a later date.</p> <ol style="margin: 10px 0px 15px 50px; padding: 0px"> <li style="margin: 0px 0px 5px 40px; padding: 0px">Our script will break if the image doesn’t have a width attribute; what are some error-handling operations we can perform to prevent our script from breaking?</li> <li style="margin: 0px 0px 5px 40px; padding: 0px">What are other MooTools methods that could work in setting the width of thefigure element?</li> <li style="margin: 0px 0px 5px 40px; padding: 0px">Is the .toInt() method a MooTools method or a native JavaScript method?</li> </ol> <p><strong>Download Auto Caption Image</strong></p> <p>You can download the source file package here. Please read README.txt for instructions on how to use this package.</p> <ul style="margin: 10px 0px 15px 50px; padding: 0px; list-style-type: none"> <li style="margin: 0px 0px 5px 20px; padding: 0px 0px 0px 20px; background-image: url('http://sixrevisions.com/wp-content/themes/SixRevisions/images/li_bullets_small.jpg'); background-repeat: no-repeat; background-position: 0% 50%"> <a href="http://joomlapanel.com/download/sr-auto-caption-1.0.zip">auto-caption</a> (ZIP, 71.3 KB)</li> </ul> <p>Using MooTools will allow you to write auto caption images on-the-fly using a bit of MooTools magic. MooTools is a powerful open-source JavaScript framework that can greatly enhance the way you build your web interfaces. The first thing we want to do is mark up our images</p> <p><strong>HTML</strong></p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">&lt;img class="captioned" src="http://www.joomlapublisher.com//red_rocks.jpg"<br />title="Photo of Red Rock Mountain." width="300" height="201" /&gt;</p> <p><strong>CSS</strong></p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">img {<br />padding:5px 0;<br />}<br />div.figure {<br />width:310px;<br />text-align:center;<br />border:1px solid #ccc;<br />background-color:#f2f2f2;<br />margin:5px;<br />float:left;<br />}<br />p.caption {<br />padding:0;<br />margin:0 0 5px 0;<br />font:italic 12px Georgia, "Times New Roman", Times, serif;<br />color:#333333;<br />}</p> <p>div.figure will be the container of our image and caption. p.caption will be our actual caption. We’re going to use MooTools to insert these two things in our Document Object Model (DOM).</p> <p><strong>The code logic: manipulating the DOM</strong></p> <p>Before we get into any code-authoring, let’s step through the logic of what we’re trying to accomplish.</p> <p>First, we’re going to select all of the images in our structure that has a class ofcaptioned. Then for each image that matches our criteria, we’re going to:</p> <ol style="margin: 10px 0px 15px 50px; padding: 0px"> <li>Determine whether it has an alt or title attribute.</li> <li>If it has neither an alt or title attribute, we don’t do anything to the image and warn the user that the image needs at least one for our script to work.</li> <li>If we find both a alt and title attribute, then we will use the title attribute value for our caption.</li> </ol> <p>Once we get the text for our caption, we will create a new DOM element, a paragraph element (&lt;p&gt;) called caption which will contain our caption text.</p> <p>Once caption is created, we’ll create another DOM element (a div) to contain our image and caption. We will call this new DOM element figure.</p> <p>Through DOM manipulation, we’re going to end up with an HTML structure like this:</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">&lt;div class="figure"&gt;<br /> &lt;img class="captioned" src="http://www.joomlapublisher.com//red_rocks.jpg"<br /> title="Photo of Red Rock Mountain." width="300" height="201" /&gt;<br /> &lt;p class="caption"&gt;Photo of Red Rock Mountain.&lt;/p&gt;<br />&lt;/div&gt;</p> <p>Of course, this will happen behind the scenes, but that’s basically what our HTML will look like after our MooTools script runs.</p> <p><strong>Initializing MooTools</strong></p> <p>Now that we have our HTML and CSS set up and we have a rough overview of what we’re going to do - we’re ready to start scripting!</p> <p>First, we’ll initialize MooTools by wrapping all of our code inside the ‘domready’ event listener.</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">window.addEvent('domready', function() {<br /> ... Our code goes in here ...<br />});</p> <p style="padding: 0px">What this method does is it tells MooTools that as soon as the DOM is ready, we’ll run our code. This way, we’re not waiting for the page to load before we execute our JavaScript.</p> <p><strong>Selecting and iterating through our images</strong></p> <p>We’ll select our images to be captioned by using the $$() function which is often called the "dollars" function. $$() is very intuitive and works almost exactly like CSS selectors. To select all images that have the class captioned, we write:</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">$$('img.captioned')</p> <p>Tip: we can also just use $$('.captioned') assuming that you only use this class for images. To be safe - I’ve chosen to increase the specificity of our selector.</p> <p>Next,we will iterate through each image that matches our criteria using the .each()method.</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">window.addEvent('domready', function() {<br /> $$('img.captioned').each(function(el) {<br /> ...Everything we write will go in here...<br /> });<br />});</p> <p><strong>Getting the text for our caption</strong></p> <p>We’re going to use the getProperty() method to pull out the title attribute value.</p> <p>We’ll put this value inside a string variable called captionText.</p> <p>To get the value, we write:</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">var captionText = el.getProperty('title')</p> <p>In our HTML markup, the value of captionText should now be:</p> <p>"Photo of Red Rock Mountain."</p> <p>But we have to consider the situation that the image might have both an alt and atitle property declared.</p> <p>So, we’re going to use a ternary control structure to check if there’s a title and if we find it, then we’ll use that for our caption; if not, we’ll try to see if there’s an altproperty and use that instead. If they both don’t exist, then captionText gets assigned a null value.</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">var captionText = ( el.getProperty('title')!=null )<br /> ? el.getProperty('title') : el.getProperty('alt');</p> <p>Note: ternary operators are just shorthand for if statements. You can easily convert the above code into nested if statements and it will work just fine. Have a go at it, convert this bit to an if structure. If you need help ask in the comments.</p> <p>In plain english, this all translates to "If the current object’s title attribute value is not null, then captionText will take on that value; otherwise, captionText will take on the value of the alt attribute."</p> <p>Explore: Here’s a good spot to explore by yourself. Try to modify our ternary operator so that the alt attribute takes precedence over the title attribute.</p> <p><strong>Making sure we have a caption</strong></p> <p>Before we do anything else, we have to make sure that our object will have a caption.</p> <p>So we make sure the captionText doesn’t contain a null value. We’ll do this with a basic if control structure</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">if ( captionText!=null ) {<br /> //code to execute if we have a caption<br />} else {<br /> //code to execute if we encounter an error (Error-handling code goes here).<br />}</p> <p><strong>Error-handling</strong></p> <p style="padding: 0px">Let’s jump ahead to our error-handling and reporting. The method we’ll use is very rudimentary: if we find that the current object doesn’t have a caption (i.e.captionText != null evaluates to false), then we’re going to tell the user that this image needs either a title or an alt attribute.</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">alert('The image: "'+el.getProperty('src')+'" needs a title or alt value.');</p> <p>To help identify the image, we take the src value, which outputs the location of our image.</p> <p>IMPORTANT: This type of error-handling and reporting isn’t good practice; we used this in the example to make things easier on ourselves. But in production, you would want to replace this code with a better way to handle errors.</p> <p><strong>Messing around with the DOM</strong></p> <p>Now, we’re going to get into the thick of things – DOM manipulation. We’re going to insert two new elements in our Document Object Model; they are figure andcaption.</p> <p>The first element we’re going to make is the figure element. This element will be adiv element that will contain our image and our other new element (caption).</p> <p><strong>Declaring our figure prototype</strong></p> <p>In order to create a new element in MooTools, we use the following structure:</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">var elementName = new Element('type of element', {its  properties})</p> <p>We want figure to be a div with a class of figure and 10 pixels wider than our image (so that we have a 5-pixel margin on the left and the right).</p> <p>Our prototype for figure then becomes:</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">var figure = new Element('div', {<br /> 'class' : 'figure',<br /> 'styles' : {<br /> 'width' : el.get('width').toInt() + 10<br /> }<br />});</p> <p>To get the width, we use the get() method, and then we convert the value to an integer with the .toInt() method. We then add 10 pixels (+ 10) to the width so that we get the 5-pixel margin on either sides of the image.</p> <p>Are you with me so far? Keep up, we’re almost there!</p> <p><strong>Declaring our caption prototype</strong></p> <p>So we just built our first new element, figure. Now we have to build our second element, caption. caption will be a paragraph element (&lt;p&gt;) and will contain the caption’s text we took from our image (remember: it’s inside captionText).</p> <p>Let’s get right to it, here’s our caption element prototype:</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">var caption = new Element('p', {<br /> 'class' : 'caption',<br /> 'html' : captionText<br />});</p> <p>Review: Go to the MooTools Doc entry on the Element method: constructor to learn more about creating new elements.</p> <p>In the above construction, we created a new element called caption. We told MooTools that we want it to be a paragraph (&lt;p&gt;) element that has a class ofcaption and the HTML that should be inside it is equal to captionText.</p> <p><strong>Manipulating the DOM</strong></p> <p><strong>Wrapping our object inside figure</strong></p> <p>The first DOM manipulation that we’ll pull off is wrapping our object inside ourfigureelement. We’ll use the wraps() method which (as the name implies) wraps the target object of the method with the argument you pass into it.</p> <p>with this in mind, all we have to do is write:</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">figure.wraps(el);</p> <p><strong>Inserting caption into the DOM</strong></p> <p>After that, we want to insert caption after our image. We’ll use the inject() method for this.</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">caption.inject(el,'after');</p> <p><strong>Summing up</strong></p> <p>Let’s bring everything together in one big chunk. Here’s the entire MooTools script.</p> <p style="border: 1px solid #e1e1e1; padding: 10px; background-color: #ebebeb; font-size: 12px">window.addEvent('domready', function() {<br /> $$('img.captioned').each(function(el) {<br /> var captionText = ( el.getProperty('title')!=null )<br /> ? el.getProperty('title') : el.getProperty('alt');<br /> if ( captionText!=null ) {<br /> var figure = new Element('div', {<br /> 'class' : 'figure',<br /> 'styles' : {<br /> 'width' : el.get('width').toInt() + 10<br /> }<br /> });<br /> var caption = new Element('p', {<br /> 'class' : 'caption',<br /> 'html' : captionText<br /> });<br /> figure.wraps(el);<br /> caption.inject(el,'after');<br /> } else {<br /> alert('The image: "'+el.getProperty('src')+'" needs a title or alt value.');<br /> }<br /> });<br />});</p> <p><strong>What did we just do?</strong></p> <p>In this tutorial, we used the MooTools JavaScript framework to automatically display captions below images that have the class of captioned. We did this by selecting all the elements that matched our criteria, iterated through the matched set, and for each object in the matched set, we:</p> <ol style="margin: 10px 0px 15px 50px; padding: 0px"> <li>Determined our caption’s text by getting the value of the object’s titleattribute, and if it didn’t have one, then we defaulted to its alt attribute.</li> <li>Constructed the figure element that wraps around our image and caption.</li> <li>Constructed the caption element, a paragraph that has our image’s caption.</li> <li>Wrapped our image inside the figure element using the wraps() method.</li> <li>Injected caption right after our image using the inject() method.</li> </ol> <p>We also made a very basic error-handling system that warns the user via an alert message that a title or alt value is required.</p> <p><strong>Review questions for beginners</strong></p> <p style="padding: 0px">This script is far from perfect. I chose to leave it that way to encourage you to explore MooTools and analyze the code we wrote together.</p> <p style="padding: 0px">Here are some questions to try and answer yourself. I will post the answer in the comments section at a later date.</p> <ol style="margin: 10px 0px 15px 50px; padding: 0px"> <li style="margin: 0px 0px 5px 40px; padding: 0px">Our script will break if the image doesn’t have a width attribute; what are some error-handling operations we can perform to prevent our script from breaking?</li> <li style="margin: 0px 0px 5px 40px; padding: 0px">What are other MooTools methods that could work in setting the width of thefigure element?</li> <li style="margin: 0px 0px 5px 40px; padding: 0px">Is the .toInt() method a MooTools method or a native JavaScript method?</li> </ol> <p><strong>Download Auto Caption Image</strong></p> <p>You can download the source file package here. Please read README.txt for instructions on how to use this package.</p> <ul style="margin: 10px 0px 15px 50px; padding: 0px; list-style-type: none"> <li style="margin: 0px 0px 5px 20px; padding: 0px 0px 0px 20px; background-image: url('http://sixrevisions.com/wp-content/themes/SixRevisions/images/li_bullets_small.jpg'); background-repeat: no-repeat; background-position: 0% 50%"> <a href="http://joomlapanel.com/download/sr-auto-caption-1.0.zip">auto-caption</a> (ZIP, 71.3 KB)</li> </ul> Script for Recording User IP Address 2009-09-27T07:38:50Z 2009-09-27T07:38:50Z http://www.joomlapublisher.com/75-script-for-recording-user-ip-address.html Administrator cs@balipublisher.com <p align="justify">If your website has a feature such as uploader and you want to track the people that use it, then you may want to consider using some sort of record script that will record information to somewhere. In this tutorial you can create a script that will silently record a user IP address and store all information in a .txt file, no database required!. This very usefull for your Joomla user registration form or for tracking user order come from.</p> <p align="justify">IP Logging is used alot now a days, a common place to see it happening is on sites that use shopping cart systems. You will often find that a message will be on the website somewhere stating that your IP address is being logged (For that session) you can also find IP logging on major websites such as Wikipedia.</p> <p align="justify">IP logging is present as Wikipedia is a publicly accessible knowledge base that can be edited by anyone, in order to prevent abuse they would track user's IP address to make sure they can block anyone that abuses it. IP Logging allows you to have some sort of log to look over and review to spot any interesting/query IP address which you may be suspicious of. Essentially giving you the upper hand againest someone thats abusing something. The PHP Script: Enough chit chat. Let's show the script thats going to log IP's</p> <p class="code"><br />01. 02.// Checks the current date and time<br /> <br />02.// Checks the current date and time<br /> <br />03.$dateTime = date('Y/m/d G:i:s');<br /> <br />04.// Loads the writable text file and await instruction from fwrite command<br /> <br />05.$fp = fopen('ip-log.txt', 'r+');<br /> <br />06.while (!feof($fp))<br /> <br />07.{<br /> <br />8.$buffer = fgets($fp);<br /> <br />9.// Scan for any previous logs of the IP<br /> <br />10.// If scan determines that the user is a logged IP address, overwrite existing log.<br /> <br />11.list ($ip, $crap) = split(' ', $buffer);<br /> <br />12.if ($_SERVER['REMOTE_ADDR'] == trim($ip))<br /> <br />13.$exists = TRUE;<br /> <br />14.}<br /> <br />15.// If scan determines it's user is a new IP entry, add the IP address to the log file at the end of the document<br /> <br />16.if (!$exists)<br /> <br />17.fwrite($fp, $_SERVER['REMOTE_ADDR']. " $dateTime\n");<br /> <br />18.fclose($fp);<br /> <br />19.?&gt;</p> <p>The comment marks should explain many of your questions but I'll break it down:</p> <p class="code">$dateTime = date('Y/m/d G:i:s');</p> <p>First off the script will check the current date and time. It will need to be called first otherwise the log can't process a date and time stamp.</p> <p class="code">$fp = fopen('ip-log.txt', 'r+');</p> <p align="justify">This will be your text file that the script will write all logs to. Whatever you name it and wherever it's stored you must update the filename in the script otherwise the script will throw out alot of error's.</p> <p align="justify">You will also need to make this text file writable (CHMOD 777) As a recommendation I'd place the text file you are going to use within the public_html folder so it's easily accessible. Notice the fopen command. This is needed to start the log process otherwise the script will not write anything to the text file</p> <p class="code"><br />$buffer = fgets($fp);<br /> <br />02.// Scan for any previous logs of the IP<br /> <br />03.// If scan determines that the user is a logged IP address, overwrite existing log.<br /> <br />04.list ($ip, $crap) = split(' ', $buffer);<br /> <br />05.if ($_SERVER['REMOTE_ADDR'] == trim($ip))<br /> <br />06.$exists = TRUE;<br /> <br />07.}<br /> <br />08.// If scan determines it's user is a new IP entry, add the IP address to the log file at the end of the document<br /> <br />09.if (!$exists)<br /> <br />10.fwrite($fp, $_SERVER['REMOTE_ADDR']. " $dateTime\n");<br /> <br />11.fclose($fp);</p> <p>This script will now check the log file for any previous logs of the IP Address that is being logged. The fgets command will be used to fetch the log file and check for any current logs of the same IP Address. If the IP address is new and has not been logged before then the fwrite command will write the new IP address to the log.</p> <p class="code">fclose($fp);</p> <p>The fclose command is important as it will stop the log writing any other details that could end up as bad data. It is vital it is placed as: 1. This script will slightly slow your page loading time down.</p> <p>Not adding in a close function will either effect your page loading times dramatically, or even cause endless loading times (Page will never load) 2.</p> <p>You may end up with random log data if the script does not have a stop function Security Isssues with this script: The security level of this script is low as it only records a users IP Address nothing else. If it recorded personal data or passwords it would be much more serious.</p> <p>The fact of the script not using a database may be good for some people, but in actual fact using a database would make this script more secure, but being able to make a script that can write log information to a writable text file does provide some advantages.</p> <p>The point of this script is a quick and simple way to record a users IP Address and as long as you don't advertise the fact that you have a text file thats logs IP address's no one will know. Even if you want to add a note on your website that IP addresses are logged nearly 99% of people will never know how your logging IP addresses.</p> <p>So thats how to make a silent and easy way of logging a users IP Address. I've pointed out it has issues but in the end the script does a big stop with little requirements!</p> <p> </p> <p align="justify">If your website has a feature such as uploader and you want to track the people that use it, then you may want to consider using some sort of record script that will record information to somewhere. In this tutorial you can create a script that will silently record a user IP address and store all information in a .txt file, no database required!. This very usefull for your Joomla user registration form or for tracking user order come from.</p> <p align="justify">IP Logging is used alot now a days, a common place to see it happening is on sites that use shopping cart systems. You will often find that a message will be on the website somewhere stating that your IP address is being logged (For that session) you can also find IP logging on major websites such as Wikipedia.</p> <p align="justify">IP logging is present as Wikipedia is a publicly accessible knowledge base that can be edited by anyone, in order to prevent abuse they would track user's IP address to make sure they can block anyone that abuses it. IP Logging allows you to have some sort of log to look over and review to spot any interesting/query IP address which you may be suspicious of. Essentially giving you the upper hand againest someone thats abusing something. The PHP Script: Enough chit chat. Let's show the script thats going to log IP's</p> <p class="code"><br />01. 02.// Checks the current date and time<br /> <br />02.// Checks the current date and time<br /> <br />03.$dateTime = date('Y/m/d G:i:s');<br /> <br />04.// Loads the writable text file and await instruction from fwrite command<br /> <br />05.$fp = fopen('ip-log.txt', 'r+');<br /> <br />06.while (!feof($fp))<br /> <br />07.{<br /> <br />8.$buffer = fgets($fp);<br /> <br />9.// Scan for any previous logs of the IP<br /> <br />10.// If scan determines that the user is a logged IP address, overwrite existing log.<br /> <br />11.list ($ip, $crap) = split(' ', $buffer);<br /> <br />12.if ($_SERVER['REMOTE_ADDR'] == trim($ip))<br /> <br />13.$exists = TRUE;<br /> <br />14.}<br /> <br />15.// If scan determines it's user is a new IP entry, add the IP address to the log file at the end of the document<br /> <br />16.if (!$exists)<br /> <br />17.fwrite($fp, $_SERVER['REMOTE_ADDR']. " $dateTime\n");<br /> <br />18.fclose($fp);<br /> <br />19.?&gt;</p> <p>The comment marks should explain many of your questions but I'll break it down:</p> <p class="code">$dateTime = date('Y/m/d G:i:s');</p> <p>First off the script will check the current date and time. It will need to be called first otherwise the log can't process a date and time stamp.</p> <p class="code">$fp = fopen('ip-log.txt', 'r+');</p> <p align="justify">This will be your text file that the script will write all logs to. Whatever you name it and wherever it's stored you must update the filename in the script otherwise the script will throw out alot of error's.</p> <p align="justify">You will also need to make this text file writable (CHMOD 777) As a recommendation I'd place the text file you are going to use within the public_html folder so it's easily accessible. Notice the fopen command. This is needed to start the log process otherwise the script will not write anything to the text file</p> <p class="code"><br />$buffer = fgets($fp);<br /> <br />02.// Scan for any previous logs of the IP<br /> <br />03.// If scan determines that the user is a logged IP address, overwrite existing log.<br /> <br />04.list ($ip, $crap) = split(' ', $buffer);<br /> <br />05.if ($_SERVER['REMOTE_ADDR'] == trim($ip))<br /> <br />06.$exists = TRUE;<br /> <br />07.}<br /> <br />08.// If scan determines it's user is a new IP entry, add the IP address to the log file at the end of the document<br /> <br />09.if (!$exists)<br /> <br />10.fwrite($fp, $_SERVER['REMOTE_ADDR']. " $dateTime\n");<br /> <br />11.fclose($fp);</p> <p>This script will now check the log file for any previous logs of the IP Address that is being logged. The fgets command will be used to fetch the log file and check for any current logs of the same IP Address. If the IP address is new and has not been logged before then the fwrite command will write the new IP address to the log.</p> <p class="code">fclose($fp);</p> <p>The fclose command is important as it will stop the log writing any other details that could end up as bad data. It is vital it is placed as: 1. This script will slightly slow your page loading time down.</p> <p>Not adding in a close function will either effect your page loading times dramatically, or even cause endless loading times (Page will never load) 2.</p> <p>You may end up with random log data if the script does not have a stop function Security Isssues with this script: The security level of this script is low as it only records a users IP Address nothing else. If it recorded personal data or passwords it would be much more serious.</p> <p>The fact of the script not using a database may be good for some people, but in actual fact using a database would make this script more secure, but being able to make a script that can write log information to a writable text file does provide some advantages.</p> <p>The point of this script is a quick and simple way to record a users IP Address and as long as you don't advertise the fact that you have a text file thats logs IP address's no one will know. Even if you want to add a note on your website that IP addresses are logged nearly 99% of people will never know how your logging IP addresses.</p> <p>So thats how to make a silent and easy way of logging a users IP Address. I've pointed out it has issues but in the end the script does a big stop with little requirements!</p> <p> </p>