TomatoCart

65381 Downloads
225 users online
TomatoCart Community
Welcome, Guest
Please Login or Register.    Lost Password?
Bookmark and Share

New function for personalised button
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: New function for personalised button
#608
New function for personalised button 1 Year, 10 Months ago Karma: 2
Hi,

I wrote a function to have css design button as following:
function osc_draw_css_button($class='button', $label='', $parameters=null)
{
global $osC_Language, $osC_Template;

$image_submit = '<input type="submit" class="'.$class.'"';
if (!empty($label) && isset($label))
{
$image_submit .= ' value="'.$label.'"';
}



if (!empty($parameters)) {
$image_submit .= ' ' . $parameters;
}

$image_submit .= ' />';

return $image_submit;

}

In this case, we can have a default button template (defined in the css file with hover/active...) and we can write what we want on it ($label value).

Would it be possible to add it in the includes/functions/html_output.php file for a standard access (if useful of course).

Thanks in advance,

Helgvor STOLL
helgvor_stoll
Expert Boarder
Posts: 120
graphgraph
User Offline Click here to see the profile of this user
Gender: Male Delphine Lingerie Location: SALEILLES (FRANCE) Birthday: 02/27
The administrator has disabled public write access.
 
#610
Re:New function for personalised button 1 Year, 10 Months ago Karma: 2
Sorry but I had to rewrote this function to be IE compatible (you can see a demo of its use on tomatocart.biztrak.fr - button search & add to cart). It is as following:

<?php

/**
* Generate an internal URL address for the catalog side
*
* @param string $class: classname of the button
* @param string $label: value of the button
* @param boolean $submit: if true then the button is a part of a form
* @param string $submit_link: action link of the button
*/

function osc_draw_css_button($class='button', $label='', $submit=true, $submit_link='', $parameters=null)
{
global $osC_Language, $osC_Template;

$image_submit = '<input type="submit" class="'.$class.'"';

if (!empty($label) && isset($label)) { $image_submit .= ' value="'.$label.'"'; }

if (!empty($parameters)) { $image_submit .= ' ' . $parameters; }

$image_submit .= ' />';

if (!($submit || empty($submit_link)))
{
return "<form method='post' action='".$submit_link."'>".$image_submit."</form>";
}
else
{
return $image_submit;
}

}

?>

You can then use it to draw an "add to cart" button like this:
osc_draw_css_button('buttonAddMedium', $osC_Language->get('button_add_to_cart'), false, osc_href_link(FILENAME_PRODUCTS, $Qproducts->value('products_id') . '&action=cart_add'))
where "buttonAddMedium" is the class name of the button (to modify in the stylesheet.css file of the template) and the standard function osc_href_link permit to construct an action url.

The interest of this new function is to build one time a button (normal, hover and active css values can be defined in stylesheet.css an you can customize you button) and use it everywhere by changing the link & the label (you won't have now to drow one button per action and per language).

Hope it can help you for templating and welcome in the tomatocart promising adventure.

Helgvor STOLL
helgvor_stoll
Expert Boarder
Posts: 120
graphgraph
User Offline Click here to see the profile of this user
Gender: Male Delphine Lingerie Location: SALEILLES (FRANCE) Birthday: 02/27
The administrator has disabled public write access.
 
#617
Re:New function for personalised button 1 Year, 10 Months ago Karma: 29
We have thought of using CSS to draw button before, but we decide to make it later. With CSS we can only make simple button.

If we want to make vista style button with round corner and lighting effect, then it is very difficult. We can not simply use image as background for button or link, as the length of the text are not fixed. Then we have to consider some advanced CSS technology; for example, insert a "span" element in the "a" link element to make round button.

Anyway, improving our template system and making more advanced UI effect for store front is our primary task after our first stable release.
zheng.lei
Team Member
Posts: 462
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to top Page: 1
Moderators: mkorayt, GuyaneseG

Latest Blog Post

TomatoCart v2.0 – An open source ecommerce framework

Since the TomatoCart v1.0’s framework getting old and the core is not a pure MVC design, it causes many troubles ...

Blog | Administrator | Saturday, 21 January 2012

More in: About Us

-
+
3

contact_us

TomatoCart
+86-13771170725
info@tomatocart.com
http://www.tomatocart.com

Newsletter Subscription

Name:

E-Mail:

Verification Code:
Captcha

Receive HTML?