Support > cpg1.5 miscellaneous

Open Graph meta data for coppermine

<< < (2/8) > >>

Anturaju93:
I think i need to edit theme.php and add this function function pageheader($section, $meta = '') from sample theme but i don't know how to construct the $meta
I tried $meta = <meta property="og:url" content="link here" /> but is not working, my site is crashing.   

--- Code: ---//meta open graph
    $meta = <<<EOT <meta property="og:url" content="link aici" /> EOT;
--- End code ---
Some ideas ?

Anturaju93:
I added this to theme.php :

--- Code: ---/******************************************************************************
** Section <<<pageheader>>> - START
******************************************************************************/
function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir;

    // Variabile pentru aflarea pid-ului unic START
    $superCage = Inspekt::makeSuperCage();
    $pid = $superCage->get->getInt('pid');
    // Variabile pentru aflarea pid-ului unic END

    $custom_header = cpg_get_custom_include($CONFIG['custom_header_path']);

    $meta = '<meta property="og:url" content="http://imagini.moinesti.biz/displayimage.php?pid=$pid" />';

    $charset = ($CONFIG['charset'] == 'language file') ? $lang_charset : $CONFIG['charset'];

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
    header("Content-Type: text/html; charset=$charset");
    user_save_profile();

    $template_vars = array(
        '{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => theme_page_title($section),
        '{CHARSET}' => $charset,
        '{META}' => $meta,
        '{GAL_NAME}' => $CONFIG['gallery_name'],
        '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
        '{SYS_MENU}' => theme_main_menu('sys_menu'),
        '{SUB_MENU}' => theme_main_menu('sub_menu'),
        '{ADMIN_MENU}' => theme_admin_mode_menu(),
        '{CUSTOM_HEADER}' => $custom_header,
        '{JAVASCRIPT}' => theme_javascript_head(),
        '{MESSAGE_BLOCK}' => theme_display_message_block(),
    );

    $template_vars = CPGPluginAPI::filter('theme_pageheader_params', $template_vars);
    echo template_eval($template_header, $template_vars);

    // Show various admin messages
    adminmessages();
}
/******************************************************************************
** Section <<<pageheader>>> - END
******************************************************************************/


--- End code ---
You can see that i defined $meta = '<meta property="og:url" content="http://imagini.moinesti.biz/displayimage.php?pid=$pid" />'; witch displays <meta property="og:url" content="http://imagini.moinesti.biz/displayimage.php?pid=$pid" /> in browser meta data, but i can`t make the URL to by dynamic: imagini.moinesti.biz/displayimage.php?pid=$pid stays the same and does not change into imagini.moinesti.biz/displayimage.php?pid=140 etc. ...

E. William:
Try replacing:

--- Code: ---    $meta = '<meta property="og:url" content="http://imagini.moinesti.biz/displayimage.php?pid=$pid" />';
--- End code ---

with:

--- Code: ---    $meta = '<meta property="og:url" content="http://imagini.moinesti.biz/displayimage.php?pid=' . $pid . '" />';
--- End code ---

so it doesn't read $pid as part of the url, but as a variable.

Not sure if it'll do the trick, that depends on other parts of the code as well, but it'll get you closer to where you want to be.

Anturaju93:
Yes, is working now, thanks.   8)
This is only half fixed, i need now to display this custom meta data only on displayimage.php and i need to insert another meta data into $meta , the image file location for facebook to use with the share button to create a timeline story. <meta property="og:image" content="dynamic and direct path to file location" />
Facebook share looks very nice now with this new open graph data :)

E. William:
That code would look something like:


--- Code: ---    $meta = '<meta property="og:url" content="http://imagini.moinesti.biz/displayimage.php?pid=' . $pid . '" />';

    if ($CONFIG['make_intermediate'] && cpg_picture_dimension_exceeds_intermediate_limit($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight'])) {
        $meta .= '<meta property="og:image" content="http://imagini.moinesti.biz/' . "{$CURRENT_PIC_DATA['filepath']}" . 'normal_' . "{$CURRENT_PIC_DATA['filename']}" . '" />';
    } else {
        $meta .= '<meta property="og:image" content="http://imagini.moinesti.biz/' . "{$CURRENT_PIC_DATA['filepath']}" . "{$CURRENT_PIC_DATA['filename']}" . '" />';
    }
--- End code ---

I must say I'm not a coder either, so I can't guarantee this will work. You may have to tweak the code here and there.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version