Search Blog Posts

Posts Tagged ‘PHP’

PHP capitalising the first letters of each word in a sentance

Friday, June 27th, 2008

I recently wanted a contact form to convert a form element, in this case someones name to uppercase. For example ‘tom peters’ decided to enter his name without any capitals. The desired result would ideally be ‘Tom Peters’.

Using PHP we can convert the form field variable by doing the following:

$personsname= "tom peters";
$PersonsName = ucwords($personsname);

echo "<p>The old string - $personsname <br />";
echo "The new string - $PersonsName </p>";

There are a few more examples that you could experiment with for example:
strtolower(); will convert a string to lowercase.
strtoupper(); will convert a string to uppercase.

PHP For Loop…as simple as this!

Sunday, June 15th, 2008

[code]for ( $count = 5; $count <= 5; $counter ++) {
echo $counter;
echo ” <br />”;
}[/code]

Excluding Posts from the Index Page on Wordpress

Tuesday, June 3rd, 2008

If you have ever wanted to exclude posts from your homepage on wordpress keep reading…..

Excluding posts on the index page of the blog was one of those things that i knew was possible but never really got around to actually doing it!

I thought i would share the solution to the problem as i managed to find a quick and easy way of excluding the posts.

Here’s how you do it

Step 1
Locate the index.php file in your current active theme. This is usually situated in the ‘wp-content/themes/’ folder of your server. Once you have located this folder pick your current theme and look inside to find the index.php file. You will then need to download this file and open in your default editor.

Step 2
Once you’ve managed to open the file do a search for the following line of code:
<?php while (have_posts()) : the_post(); ?>

You will then need to insert the following code so you have something that looks like this:
<?php while (have_posts()) : the_post(); ?>
<?php if (in_category('79')) continue; ?>

Step 3
Notice that the category 79 has been used in this example.
To find the id of the category that you want to exclude from the homepage simply login to your admin page and head over to the manage > categories section. Once there simply mouse over the category name that you wish to exclude and notice in the url there will be an id number (this normally displayed to the bottom of your browser).

Extra Steps
If you want to exclude multiple categories simply duplicate the same line of code as shown above changing the id number. See the example below:

<?php while (have_posts()) : the_post(); ?>
<?php if (in_category('79')) continue; ?>
<?php if (in_category('29')) continue; ?>
<?php if (in_category('30')) continue; ?>
<?php if (in_category('12')) continue; ?>

This is its as simple as that!

CSS Navigation Examples

Tuesday, June 3rd, 2008

Navigation / Drop down Navigation in CSS can cause many problems across different browsers browsers.

After crawling the net i managed to stumble across a good site with some very nice examples, both build wise and visually.

The site links to a number of Horizontal and Vertical drop down menus. 

Click here to check them out.

PHP Include function

Monday, June 2nd, 2008

Using the php include(); statment can be a handy way to speed up your development time , making it easier to amend or add features to a set template or snippet of code.

I have uploaded a zip file with an example of a few include statements. This can be found at the bottom of this post.

Example Code

<?php include("includes/filename.php"); ?>

Take a look at the attached example and see how you can use the php include function to speed up your development time.

Things to note

Unless your machine is set up to allow php files to run locally you will need to upload it to your server to test.

Download

PHP Include Example Download

How to Validate an Entire Website - XHTML, CSS, RSS & Links

Saturday, March 29th, 2008

So you’ve just build your complete website and its almost read to go live…. but have you validated it making sure its compliant to w3c standards?

Where to validate

Of course you can head straight over to the w3c.org website where you can:
Validate your XHTML
Validate your links
Validate your CSS
Validate your RSS/Feed

But fingers crossed someone has already or they are working on creating an all inclusive validator to do all of these things in one go.

Dont forget to spell check!! I advise you use the default spell checker in what ever software you are using to create your website, another way you could check is by using an online checker such as http://www.wellho.net/demo/spell.php how ever please bare in mind that this is a free service and only checks single pages.

In my travels i also stumbled accross the WDG HTML Validator, which is available at http://htmlhelp.com/tools/validator/ not only can you check a websites validation, you can check to see if the entire site is validating, this is also very hand as one of its features enabled you to see if your internal pages are linking to pages that dont exist.

Why validate?

Well there are many reason too validate, take a look at the following website for an explanation of reasons to validate - click here to read more.

Give it a go, it worked well for me.

Returning the Current Page URL

Sunday, March 2nd, 2008

Using PHP you can return the current url of the page by simply using :

$pageURL = 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
echo $pageURL;

By using string manipulation you can also us this function to return the end characters of the url request.

For the following url: http://minimalistics.co.uk/gallery/main.php?g2_itemId=89 we can return the end numbers using the following code:
$pageURL = 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
$pageURL = substr($pageURL,strrpos($pageURL,"=")+1);
echo $pageURL;

The result of this would be 89.

How to Test your Websites Loading Speed

Tuesday, February 19th, 2008

After stripping and streamlining my xhtml, css, javascript, php and images for the design and launch of the new website i thought id do a little hunting for a decent website speed checker.

I managed to find ‘Web Page Analyzer‘ which is a free web page analysis tool that calculates page size, composition, and download time and gives speed recommendations based on best practices for usability, HCI, and website optimisation.

This was not only good for showing the data that i was after but it highlighted files that were larger than first expected and pointed out a couple of small but non important errors.

Give it a go.

Changing the right click menu in flash

Monday, February 11th, 2008

Right Click Menu in FlashChanging the right click menu in flash files is relitivley simple. Using the code below and placing it on the root of your document you can add a new right click menu to your published files. This disables the existing zoom in, zoom out ect and enables you to attach functions to the buttons, whether it be launching a new web page or changing the colour of the movie clip document.

So heres what to do:

Paste the following code onto the root of your flash document, directly onto a blank frame, publish your movie, Job done!

And heres the code:

//define any functions to included on a menu item
function launchsite1(){
getURL("http://www.minimalistics.co.uk", _blank);
}

function launchsite2(){
getURL("http://www.minimalistics.co.uk/contact.php", _blank);
}

////Declare a new menu item
newmenu = new ContextMenu();//Hide the built in flash menu
newmenu.hideBuiltInItems();//define your new menu items
item1 = new ContextMenuItem("My Home Page", launchsite1);
item2 = new ContextMenuItem("Another Web Page", launchsite2);
newmenu.customItems.push(item1);
newmenu.customItems.push(item2);//Build New Menu
_root.menu = newmenu;

You can change add or remove any of the items above to suit your requirements.

The Concept behind the project

Tuesday, June 12th, 2007

The Readymade Generator – Alan Bourne – 273616 – iDAT203 – Conceptual Art

The beginning
Initially this project started life tackling the idea of concepts and the methods and approaches with which we come up with concepts. The direction in which I approached this idea was by developing ideas and prototypes to understand how we create concepts, and more importantly what is a good concept? To try to answer this problem I set myself the challenge of designing a concept generator. This would hopefully benefit me and help tackle the question to provide a concept for me to work with. After only 2 weeks developing the generator my ideas and concept shifted.

The concept generator has evolved into the Readymade Generator which is presented to you today. It can be argued that the concept generator did the job exactly as that it was designed for. From the initial concept generator prototype the readymade generator was born.

Concept
My concept is now clear and it challenges the use of online sources to create user generated readymade art. If a readymade is “an object manufactured for some other purpose, presented by an artist as a work of art” (Readymades no date) why can’t that object be from an online source?
The main idea and workings behind the Readymade Generator is to claim objects from the internet (such as images or text) and then allow an artist to rearrange the design and layout, giving the objects new meaning.

The images produced by the Readymade Generator in collaboration with the user or ‘Artist’ raise the same point as Marcel Duchamp did with his Readymades. The generated images can “be seen as a sort of irony to defining art itself, because the images say here it is, a thing that I call art, I didn’t even make it myself” (Ades et al.1999; 151).

The produced work is determined by the artist, he or she must set down the rules of the content by specifying the keywords on which the system performs its searches.

When all of the objects have been loaded into the system the user must then decide which objects should be included in the final piece. Image and text choices have to be made and layout and position of the objects are also factors that the artist must also decide. These are the processes any artist must make whether the work is of a digital or physical nature.

The artist then has the choice or deciding to include their work in the online gallery, or to discard the work entirely. The images in the gallery have been previously uploaded by other artists, these artworks and images produced from the Readymade generator are products of the artist.

By including an online art work gallery artists can submit their work, this is included for a reason. Like many artists not all of their work is displayed in galleries, some artists work gets left behind, forgotten about or the artist is just not happy with the work. By allowing users to upload their work they are saying that the work is complete, finished or done with. This is also true for the inclusion of an artist signature which the artist must make the choice to sign the work.

The images may seem meaningless and of an unaesthetic nature, however this is the exact point that the project is trying to create. The produced images are designed to take the meaning of the existing images and text out of context, to give them a new meaning.

Technical implementation
The system has been created in Adobe Flash making it accessible to all users who have the internet or access to a PC/Mac. By using a number of current technologies the system semantically pulls information from the web depending on user keyword searches. The information and data is displayed using Actionscript 2 scripting making the system dynamic and ever changing, this also allows user interaction with the retrieved objects, which in turn results in some freedom of expression for the individual artist and creates difference in the resulting piece. PHP coding is also used to obtain website html code which is later used in the application for data filtering and dynamic display. The scripts website location is determined by the system rules and user keywords. This information then builds a URL for the PHP code to rip.

Currently the system uses three online sources for its content. Google was decided on early in the project development stage as research showed that its image results are one of the best, this also provides advanced image search results which are retrieved and dynamically loaded. By using Google image search the system is able to claim resources from the entire web. Based on keyword search relevancy, images are pulled from Google and displayed in a random fashion. Their layer hierarchy when stacked, is based on there position in Google’s search page, so the more relevant images appear much clearer. As Google rescans content on a regular basis the position of the images will change, this also allows for expansion of the project as new images appear online and are scanned by Google, they too can be included.

English Wikipedia pages have also been integrated as part of the search, if the precise words are entered correctly; content from Wikipedia is loaded into the title area and the scrollable text box area. The reason Wikipedia was used for this content is its Web 2 properties, the content is ever changing and this allows expansion for the project, as the site develops more and more information will be retrieved. Questions have been raised regarding Web 2 and its validity of information but for the purpose of this project the meaning of the text is irrelevant the content is what counts.

Finally the last resource that has been included is Artistquotes.net, this has been implemented to include famous artist quotes, this is highly dependant on keyword searches but returns a number of relevant results when the correct names are used.

Evaluation
I believe that the system I have created backs up all of the research and theory behind the concept and design. As discussed earlier it has been designed with the idea of expansion in mind, by using the ever-growing online sources the possibilities are infinite. At present the system is still very limited as Artists Quotes and Wikipedia results require accurate user input but due to the time constraints this is something that had to be over looked slightly. In the future I see the system implementing voice recognition, this could also be linked up to music to generate the readymade artwork.

Bibliography
Ades, D., Cox, N. & Hopkins, D. (1999), Marcel Duchamp, Thames and Hudson, London. Godfrey, T. (1998), Conceptual Art, Phaidon Press Limited, London. Paul, C. (2003), Digital Art, Thames and Hudson, London. Stallabrass, J. (2003), Internet Art , Tate Publishing, London. Wood, P. (2002), Movements in Modern Art - Conceptual Art, Tate Publishing, London.

Webography
Readymades (no date) [online] Available: http://www.artlex.com/ArtLex/r/readymade.html [date accessed: 08 April 2007]

© Copyright 2003-2008 Minimalistic Designs | Terms | Links | Sitemap
Website Design Liskeard - www.minimalistics.co.uk