redux-framework icon indicating copy to clipboard operation
redux-framework copied to clipboard

Cant display saved data

Open oshrib opened this issue 13 years ago • 27 comments

Hi, first - amazing work !

I worked with SMOF till now, but my knowledge not help me to get here on Redux saved data.

On the option admin i can saved the data and it really saved it, but i cant to display it on the site.

Functions.php

              /**
             * Set up Admin
             */

             if(!class_exists('ReduxFramework')){
             require_once(dirname(__FILE__) . '/admin/framework.php');
             }

             require_once(dirname(__FILE__).'/admin/options.php');

Options.php:

$args['opt_name'] = 'data';

On next of options.php:

        array(
            'id'=>'logo_image',
            'type' => 'media', 
            'title' => __('Logo image', 'redux-framework'),
            'subtitle' => __('Upload any media using the Wordpress native uploader', 'redux-framework'),
            ),

                            array(
            'id'=>'text',
            'type' => 'textarea',
            'title' => __('Text', 'redux-framework'), 
            'subtitle' => __('Paste your Google Analytics (or other) tracking code here. This will be added into the footer template of your theme.', 'redux-framework'),
            'validate' => 'js',
            'desc' => 'Validate that it\'s javascript!',
            ),

Framework.php:

       public function __construct( $sections = array(), $args = array(), $extra_tabs = array() ) {
        // Create defaults array
        $defaults = array();
        $defaults['opt_name']           = ''; // Must be defined by theme/plugin
        $defaults['google_api_key']     = ''; // Must be defined to add google fonts to the typography module
        $defaults['last_tab']           = '0';
        $defaults['menu_icon']          = REDUX_URL . 'assets/img/menu_icon.png';
        if (defined('MP6')) {
            $defaults['menu_icon']      = '';
        }
        $defaults['menu_title']         = __( 'Options', 'redux-framework' );
        $defaults['page_icon']          = 'icon-themes';
        $defaults['page_title']         = __( 'Options', 'redux-framework' );
        $defaults['page_slug']          = '_options';
        $defaults['page_cap']           = 'manage_options';
        $defaults['page_type']          = 'menu';
        $defaults['page_parent']        = 'themes.php';
        $defaults['page_position']      = null;
        $defaults['allow_sub_menu']     = true;
        $defaults['show_import_export'] = true;
        $defaults['dev_mode']           = true;
        $defaults['system_info']        = true;
        $defaults['admin_stylesheet']   = 'standard';
        $defaults['footer_credit']      = __( '<span id="footer-thankyou">Options panel created using <a href="' . $this->framework_url . '" target="_blank">Redux Framework</a> v' . $this->framework_version . '</span>', 'redux-framework' );
        $defaults['help_tabs']          = array();
        $defaults['help_sidebar']       = __( '', 'redux-framework' );
        $defaults['theme_mods']         = false;
        $defaults['theme_mods_expand']  = false;
        $defaults['transient']          = false;
        $defaults['global_variable']    = '';
        $defaults['transient_time']     = 60 * MINUTE_IN_SECONDS;

header.php:

                  <?php global $data; ?>
                  < img src="<?php echo $data['logo_image'] ?>" /><?php echo $data['text'] ?> 

what i forgot to do ? what am i doing wrong?

oshrib avatar Sep 18 '13 07:09 oshrib

Okay here's my setting. I'M using roots theme and copied all the files to options inside the themefolder. Than in functions.php i have this code.

require_once locate_template('/lib/custom.php'); // Custom functions if(!class_exists('ReduxFramework')){ require_once(dirname(FILE) . '/options/framework.php'); } require_once(dirname(FILE).'/options/sample/sample-config.php');

Please note the call of custom.php here i have my options output and did it that way:


body {
background: url('<?php echo $roots['patterns']; ?>') <?php echo $roots['bgrepeat']; ?>;
font-family: <?php echo $roots['bodyfont']['family']; ?>;
font-size: <?php echo $roots['bodyfont']['size']; ?>px;
font-style: <?php echo $roots['bodyfont']['style']; ?>;
color: <?php echo $roots['bodyfont']['color']; ?>;
line-height: <?php echo $roots['bodyfont']['height']; ?>px;
}

Next step is to call the hook for printing out the inlinestyles and i do that inside the functions.php

add_action( 'wp_head', 'mytheme_dynamic_css' );

Thats all. You have to keep in mind to set the globals $your_var.

You can set your var inside the the sample_config.php and change this line to your needs:

// Set a custom option name. Don't forget to replace spaces with underscores! $args['opt_name'] = 'roots';

tonibecker avatar Sep 18 '13 08:09 tonibecker

@tonibecker Thanks... but i dont sure:

  1. why you have custom.php + sample-config in functions.php? you need only one no?
  2. I set the $args['opt_name'] = 'data'; - as you can see on my code example

dont understand why i stacked on this part... really dont understand.

Please who can - look on my code and find what i am doing wrong, i really want to use Redux on my new theme ...

oshrib avatar Sep 18 '13 08:09 oshrib

I'm using roots. So i can split my functions into different files. So i can keep the structure clear. Where do you call the options? I mean in wich file. In your first line you have to set global $data

tonibecker avatar Sep 18 '13 09:09 tonibecker

Are you using version 3 or 2? If you are using version 2 than you should call it this way. $options = get_option('data'); global $options

echo $options['identifier'];

tonibecker avatar Sep 18 '13 09:09 tonibecker

Version 3

oshrib avatar Sep 18 '13 11:09 oshrib

I never give up but it look like i cant figure so simple thing so...

oshrib avatar Sep 18 '13 11:09 oshrib

I want to understand, if i download now Radux 3.0, and i install it , and dont change nothing... if i will use $twentytwelve22['somthing'] it will work?

Tried - nothing. still not get data.

oshrib avatar Sep 18 '13 11:09 oshrib

can u grant access to your ftp? will have a look. Mail to me [email protected]

tonibecker avatar Sep 18 '13 12:09 tonibecker

@tonibecker - thanks again :)

Its on localhost, but really - think it fresh site, blank site. just Redux that downloaded + some basic wordpress php files like header and footer.

What exact the steps to do?

oshrib avatar Sep 18 '13 12:09 oshrib

whats inside your functions.php please paste your code. And where do you call the options from? Template and so on.

tonibecker avatar Sep 18 '13 12:09 tonibecker

Fresh functions.php with

          /**
         * Set up Admin
         */

         if(!class_exists('ReduxFramework')){
         require_once(dirname(__FILE__) . '/admin/framework.php');
         }

         require_once(dirname(__FILE__).'/admin/options.php');

The options is on : themefolder/admin/options.php

Calling the $data['identi..'] from hedaer.php

oshrib avatar Sep 18 '13 12:09 oshrib

please look inside your folder. there is a folder sample and inside this is sample_config.php if(!class_exists('ReduxFramework')){ require_once(dirname(FILE) . '/your_redux_folder/framework.php'); } require_once(dirname(FILE).'/your_redux_folder/sample/sample-config.php');

than in sample_config.php define the $args['opt_name'] = 'data';

go somewhere in a template file,m let's say page.php and add this global $data and call your option echo $data['your_identifier_from_sample_config.php'];

tonibecker avatar Sep 18 '13 12:09 tonibecker

@tonibecker thanks again.

I use underscores_me theme, maybe it make trouble. tomorrow i will try on total fresh wordpress theme files without nothing, because your idea on last message make me sense and it still not working, so i guess i have code line that make here trouble.

oshrib avatar Sep 18 '13 13:09 oshrib

For more details, we just updated the getting started page found here: http://reduxframework.com/docs/getting-started/

Re-open this if your issue was not resolved.

@tonibecker, thanks for helping @oshrib out!

dovy avatar Sep 18 '13 15:09 dovy

@dovy @tonibecker

Hi , thanks you all, and for the good doc. i cant explain, but it not working for me. i installed it on server, on Twenty Thirteen theme, and still - cant get the data.

Wordpress

Done, not need :)

FTP

Done, not need :)

Sorry for the "Radux" and not "Redux" :)

Dont worry, i going to delete this server account in 24 hours, its just developer environment for you to help me :)

Thanks for who will check it !

I install there Redux, without any change on opt_name, its as it comes and on header.php i added on line 34: on line 39: < img src="" />

and offcourse i installed Redux on functions.php first lines.

hope to understand what is stacking me here.

oshrib avatar Sep 20 '13 12:09 oshrib

@oshrib Fixed. You were using the release of 3.0, and we've added the global stuff to the actual repo not in the official release yet.

Also you had the opt_name wrong. I have corrected it all.

http://wbzit.com/

There you go!

dovy avatar Sep 20 '13 14:09 dovy

@dovy Dont know how to thank you.

I belive i will run from here with my cool theme, i will credit Redux and hope to be able to help in any way.

oshrib avatar Sep 20 '13 14:09 oshrib

@oshrib Just an FYI, we'll be shifting redux to run as a plugin. I'd suggest you use it that way. Build your theme and I'll show you how to do so later.

;)

dovy avatar Sep 20 '13 14:09 dovy

@dovy we'll still have the ability to use redux as embedded with only a few minor changes, right? Sort of like how SimpleOptions works?

teamcrisis avatar Sep 20 '13 14:09 teamcrisis

@teamcrisis There will be an announcement about that shortly. The answer is yes, the ability will be there. If you want to will be another question. ;)

dovy avatar Sep 20 '13 14:09 dovy