Page 1 of 1
url variable with text
Posted: Fri Jun 24, 2016 10:16 am
by sherryr
Perhaps a basic question but not obvious for me.
I have a variable $website which plugs in a link that users enter for registering for an event.
I can output this in my website where the url shows up and is linkable which is great.
What I want is that instead of the website url showing up the word Register with the value of this link around the word.
So this shows url ie
http://www.google.ca
<?php echo $website ?>
but I need the word register to be within this variable. so that
So I want
Register to show up with $website value around the word.
Can someone assist me here?
thx
Re: url variable with text
Posted: Fri Jun 24, 2016 3:44 pm
by Celauran
Do you mean like this?
Code: Select all
<a href="<?= $website; ?>">Register</a>
Or am I completely misunderstanding you?
Re: url variable with text
Posted: Mon Jun 27, 2016 2:07 pm
by sherryr
thanks for the post. see url this is what this produces and the word Register is not a link.
http://argyllengraving.com/sandbox/register.png
Re: url variable with text
Posted: Mon Jun 27, 2016 2:21 pm
by Celauran
Looks like mismatched ". Not much else I can say based on that image alone. Might be more helpful to post the generated HTML.
Re: url variable with text
Posted: Mon Jun 27, 2016 9:18 pm
by sherryr
I don't think my post worked so reposting.
so if $website = tribe_get_event_website_link (); in the dashboard
I want the word register to show up with appropriate link for each event.
I added your code - <a href="<?= $website; ?>">Register</a>
but got what you see in the image which is partial url (google) and word register is not a link.
thx
Re: url variable with text
Posted: Tue Jun 28, 2016 4:47 am
by Celauran
Can you post more of the surrounding code, as well as the rendered output? Posting no code and a tiny image is basically asking us to guess.
Re: url variable with text
Posted: Tue Jun 28, 2016 8:09 am
by sherryr
here is the page code. you can see I am trying to get it to print Register at the bottom.
--
Code: Select all
<?php
/**
* Single Event Meta (Venue) Template
*
* Override this template in your own theme by creating a file at:
* [your-theme]/tribe-events/modules/meta/venue.php
*
* @package TribeEventsCalendar
*/
if ( ! tribe_get_venue_id() ) {
return;
}
$phone = tribe_get_phone();
$website = tribe_get_venue_website_link();
?>
<div class="tribe-events-meta-group tribe-events-meta-group-venue">
<h3 class="tribe-events-single-section-title"> <?php esc_html_e( tribe_get_venue_label_singular(), 'the-events-
calendar' ) ?> </h3>
<dl>
<?php do_action( 'tribe_events_single_meta_venue_section_start' ) ?>
<dd class="tribe-venue"> <?php echo tribe_get_venue() ?> </dd>
<?php if ( tribe_address_exists() ) : ?>
<dd class="tribe-venue-location">
<address class="tribe-events-address">
<?php echo tribe_get_full_address(); ?>
<?php if ( tribe_show_google_map_link() ) : ?>
<?php echo tribe_get_map_link_html(); ?>
<?php endif; ?>
</address>
</dd>
<?php endif; ?>
<?php if ( ! empty( $phone ) ): ?>
<dt> <?php esc_html_e( 'Phone:', 'the-events-calendar' ) ?> </dt>
<dd class="tribe-venue-tel"> <?php echo $phone ?> </dd>
<?php endif ?>
<?php if ( ! empty( $website ) ): ?>
<dt> <?php esc_html_e( 'Website:', 'the-events-calendar' ) ?> </dt>
<dd class="url"> <?php echo $website ?> </dd>
<?php endif ?>
<?php do_action( 'tribe_events_single_meta_venue_section_end' ) ?>
<div id="register">
<a href="<?= $website; ?>">Register</a></div>
Re: url variable with text
Posted: Tue Jun 28, 2016 8:16 am
by Celauran
Have you inspected the value of $website after it gets set? Also, what is the output of this page?
Re: url variable with text
Posted: Tue Jun 28, 2016 8:33 am
by sherryr
the value of $website prints the url which is great but not within the word register.
Not sure if this helps
--
Code: Select all
<?php
// Event Website
if ( ! empty( $website ) ) : ?>
<dt> <?php esc_html_e( 'Website:', 'the-events-calendar' ) ?> </dt>
<dd class="tribe-events-event-url"> <?php echo $website; ?> </dd>
<?php endif ?>
<?php do_action( 'tribe_events_single_meta_details_section_end' ) ?>
Re: url variable with text
Posted: Tue Jun 28, 2016 8:39 am
by Celauran
Are you saying the above code works? If $website contains the correct value, I don't see why it wouldn't echo it.
Re: url variable with text
Posted: Tue Jun 28, 2016 8:58 am
by sherryr
so if I input
http://www.google.ca when creating the event as registration link as example it will output
http://www.google.ca
but I can't get it to output
Register (with google link around the word using the code you provided below)
<a href="<?= $website; ?>">Register</a>
it comes out like this *register has no link around it
http://argyllengraving.com/sandbox/register.png
Re: url variable with text
Posted: Tue Jun 28, 2016 9:20 am
by Celauran
Went and looked at the generated source myself.
Code: Select all
<div id="register">
<a href="<a href="http://www.google.ca" target="_self">http://www.google.ca</a>">Register</a></div><BR><BR>
This is what's being output. Looks like tribe_get_venue_website_link() returns the entire anchor tag, not just the URL. I'd check the documentation to see if there's an alternate function you can use to get just the URL.