1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Assign link to variables

Discussion in 'PHP' started by Webinator, Aug 10, 2015.

  1. #1
    Hello everyone,

    I'm in wordpress and I have this template file :

    <?php
    
                $member_ID = $ut_global_member_count;
    
                foreach ( $team as $key => $member ) :
    
                $clear = '';
    
                ?>
    
                <div class="member-box ut-member-style-3 <?php echo $ut_member_box_size; ?> <?php echo $grid[$ut_member_in_row]['class']; ?>">         
    
                <?php $avatar_style = 'ut-square'; ?>
    
                <?php //$avatar_style = $member['ut_avatar_style']; ?>
    
                <div class="mp-holder">
    
                <?php if(!empty( $member['ut_member_pic'] )) : ?>
    
    
                <figure class="member-photo-style-3">
    
               
    
                <a href="<?php echo $member['ut_member_pic']; ?>">
    
    
    
               
    
                    <img
    
                        class="utlazy"
    
                        src="<?php echo THEME_WEB_ROOT; ?>/images/placeholder/team-member.png"
    
                        alt="<?php echo $member['ut_member_name']; ?>"
    
                        data-original="<?php echo ut_resize( $member['ut_member_pic'] , 560 , (
    
                            $avatar_style == 'ut-circle' ? 560 : 420
    
                        ), true , true , true); ?>"
    
                    >
    
                </a>
    
                </figure>
    PHP:

    So, is outputting three images within a anchor tag and the link of the Url of each image.

    What I want to do is :

    assign a link to each image,

    for example:

    image one : www.mysite.org/scott-garret

    image two : www.mysite.org/brian-adams

    image three : www.mysite.org/jim-morrison


    To do that I want to replace the $member['ut_member_pic'] with a function call.


    I want to create a function in function.php that does something like this:


    
    
    function function add_link_to_photo() {
    
    
        if ($member['ut_member_name'] = (’Scott Garret’)){
    
    
                echo $scott_garret_link ;
    
                }
    
    ifesle ($member['ut_member_name'] = (’Brian Adams’)){
    
    
    echo $brian_adams_link ;
    
    }
    
    ifesle ($member['ut_member_name'] = (’Jim Morrison’)){
    
    
    echo $jim_morrison_link ;
    
    }
    
    
    PHP:

    Then I will change the file in something like this :

    <?php
    
                $member_ID = $ut_global_member_count;
    
                foreach ( $team as $key => $member ) :
    
                $clear = '';
    
                ?>
    
                <div class="member-box ut-member-style-3 <?php echo $ut_member_box_size; ?> <?php echo $grid[$ut_member_in_row]['class']; ?>">         
    
                <?php $avatar_style = 'ut-square'; ?>
    
                <?php //$avatar_style = $member['ut_avatar_style']; ?>
    
                <div class="mp-holder">
    
                <?php if(!empty( $member['ut_member_pic'] )) : ?>
    
    
                <figure class="member-photo-style-3">
    
    
    <?php 
    
    $jim_morrison_link =‘jim-morrison’;
    
    $brian_adams_link =‘brian-adams’;
    
    $scott_garret_link = ‘scott-garret’;
    
    ?>
    
               
    
                <a href="<?php  add_link_to_photo() ?>">
    
                    <img
    
                        class="utlazy"
    
                        src="<?php echo THEME_WEB_ROOT; ?>/images/placeholder/team-member.png"
    
                        alt="<?php echo $member['ut_member_name']; ?>"
    
                        data-original="<?php echo ut_resize( $member['ut_member_pic'] , 560 , (
    
                            $avatar_style == 'ut-circle' ? 560 : 420
    
                        ), true , true , true); ?>"
    
                    >
    
                </a>
    
                </figure>
    PHP:

    So… by doing this nothing is working, all stuck!

    For sure tons of syntax errors and probably a lot more, I apologize for that, I’m here for learn.

    Thanks in advance.
     
    Webinator, Aug 10, 2015 IP
  2. KangBroke

    KangBroke Notable Member

    Messages:
    1,026
    Likes Received:
    59
    Best Answers:
    4
    Trophy Points:
    265
    #2
    This should fix a good few of your errors. Run that see what happens.


    Note the changes in RED


    <?php

    $member_ID = $ut_global_member_count;

    foreach ( $team as $key => $member ) Replace : with ;

    $clear = '';

    ?>

    <div class="member-box ut-member-style-3 <?php echo $ut_member_box_size; ?> <?php echo $grid[REMOVE DOLLAR SIGN$ut_member_in_row]['class']; ?>">

    <?php $avatar_style = 'ut-square'; ?>

    <?php //$avatar_style = $member['ut_avatar_style']; ?>

    <div class="mp-holder">

    <?php if(!empty( $member['ut_member_pic'] )) Replace : with ; ?>


    <figure class="member-photo-style-3">



    <a href="<?php echo $member['ut_member_pic']; ?>">





    <img

    class="utlazy"

    src="<?php echo add here $THEME_WEB_ROOT; ?>/images/placeholder/team-member.png"

    alt="<?php echo $member['ut_member_name']; ?>"

    data-original="<?php echo add here $ut_resize( $member['ut_member_pic'] , 560 , (

    $avatar_style == 'ut-circle' ? 560 : 420

    ), true , true , true); ?>"

    >

    </a>

    </figure>














    <?php

    $member_ID = $ut_global_member_count;

    foreach ( $team as $key => $member ) Replace : with ;

    $clear = '';

    ?>

    <div class="member-box ut-member-style-3 <?php echo $ut_member_box_size; ?> <?php echo $grid[REMOVE DOLLAR SIGN$ut_member_in_row]['class']; ?>">

    <?php $avatar_style = 'ut-square'; ?>

    <?php //$avatar_style = $member['ut_avatar_style']; ?>

    <div class="mp-holder">

    <?php if(!empty( $member['ut_member_pic'] )) Replace : with ;?>


    <figure class="member-photo-style-3">


    <?php
     
    KangBroke, Aug 11, 2015 IP
  3. Webinator

    Webinator Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    Hi thanks for your help , unfortunately nothing is working.
     
    Webinator, Aug 12, 2015 IP
  4. KangBroke

    KangBroke Notable Member

    Messages:
    1,026
    Likes Received:
    59
    Best Answers:
    4
    Trophy Points:
    265
    #4
    did you actually make the changes? I pointed them out not corrected them
     
    KangBroke, Aug 12, 2015 IP