Results 1 to 3 of 3

Thread: Need some help with a php select form to show correct result

  1. #1
    Join Date
    Mar 2005
    Location
    Western Australia
    Posts
    134
    Thanks
    19
    Thanked 4 Times in 4 Posts

    Default Need some help with a php select form to show correct result

    I am working on a theme for Wordpress and I want to add a function where a user can in the theme options select a font they want to use for their content etc

    I have the basics working using the following in my options and functions files, the following are just the excerpts of the code for this particular issue;

    in my options.php file

    PHP Code:
        $options[] = array(
            
    'name' => __('Content Font''flexiness'),
            
    'desc' => __('Select the font you want to use for your main content areas.''flexiness'),
            
    'id' => 'content_font',
            
    'type' => 'select',
            
    'std' => 'arial'// as default
            
    'options' => array(
                
    'arial'          => 'Arial/Helvetica',
                
    'arial_blk'   => 'Arial Black',
                
    'comic'          => 'Comic Sans MS',
                
    'georgia'        => 'Georgia',
                
    'impact'        => 'Impact',
                
    'lucida'        => 'Lucida Sans Unicode',
                
    'palatino'      => 'Palatino Linotype',
                
    'tahoma'        => 'Tahoma',
                
    'times'          => 'Times New Roman',
                
    'trebuchet'      => 'Trebuchet MS',
                
    'verdana'        => 'Verdana, Geneva, sans-serif')
            ); 
    then in my functions php file which gets its content from the options chosen above

    PHP Code:
    $flexiness_content_font flexiness_option('content_font''arial'); // this is the default 
    Then, noting there is other style code above this including the opening style tag

    I will be adding Google font options as an alternative hence the if and or's, if they choose the google fonts instead it will output the required google link code instead of the following

    PHP Code:
    if ($flexiness_content_font == 'arial' || 'arial_blk' || 'comic' || 'georgia' || 'impact' || 'lucida' || 'palatino' || 'tahoma' || 'times' || 'trebuchet' || 'verdana'); {
    echo 
    '
        h1, h2, h3, h4, h5, h6, #theme-link, #nav-main .nav-main a, #nav-top .nav-top a, .my-title {font-family:' 
    . ($flexiness_content_font) . ';}    
    </style>' 
    "\n";} 
    The end result is that if 'arial_blk' is selected it outputs of course 'arial_blk'. How can I get it to instead output the full name like 'Arial Black', or for 'comic', output 'Comic Sans MS'

    I'm sure there is a better and more efficient way to do the above, but for now I just need to work out how I get it to output the full name.

    Hoping the above is enough to make sense
    1st rule of web development - use Firefox and Firebug
    2nd rule - see the first rule
    --
    I like Smilies

  2. #2
    Join Date
    Mar 2005
    Location
    Western Australia
    Posts
    134
    Thanks
    19
    Thanked 4 Times in 4 Posts

    Default

    All sorted, I have used a combination of the full name font and used php to title and remove underscores etc to produce the right font name and now have an optional font selection for my theme
    1st rule of web development - use Firefox and Firebug
    2nd rule - see the first rule
    --
    I like Smilies

  3. The Following User Says Thank You to gwmbox For This Useful Post:

    tuanx90 (08-15-2014)

  4. #3
    Join Date
    Aug 2014
    Posts
    1
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    i'm searching to solve this problem

Similar Threads

  1. Show different image depending on result check
    By jposttib in forum JavaScript
    Replies: 5
    Last Post: 01-05-2013, 10:11 AM
  2. Replies: 0
    Last Post: 09-16-2012, 05:17 PM
  3. Replies: 4
    Last Post: 03-01-2010, 04:39 AM
  4. Submit Any Form via Ajax and get result back on same page.
    By diltony in forum Submit a DHTML or CSS code
    Replies: 3
    Last Post: 08-05-2009, 04:50 PM
  5. Getting a form result into a Iframe
    By aclips in forum HTML
    Replies: 6
    Last Post: 10-24-2007, 07:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •