Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.

landing page to use google fonts.

Status
Not open for further replies.

Paullas

Staff member
Joined
Jul 13, 2004
Posts
5,797
Reaction score
340
Hi, i am hoping someone can help/advise.

At the moment i am using the following code to grab the url and display it on a page:


<?
$domainstart = $_SERVER['HTTP_HOST'];
$domainname = str_replace("www.", "", "$domainstart");
?>

then on the page this displays the domain name:

<? echo "$domainname"; ?>

What i am trying to do is when <? echo "$domainname"; ?> shows the url how do i go about it using google fonts.

thanks in advance.
 
Let's take a random example...

<link href='http://fonts.googleapis.com/css?family=Kite+One' rel='stylesheet' type='text/css'>

Put the above between the <head> and </head> tags

Then use the following:

<?
echo "<p style=\"font-family: 'Kite One', sans-serif;\">".$domain."</p>";
?>

You can also use a <span></span> instead of the <p></p> if you don't want to put the domain within a new paragraph.

The \ in front of the " tells PHP to display the " as a symbol, rather than process it i.e. you have to put that so that you don't drop out of the string being echo-ed.
 
Thanks edwin, I tried the above but doesnt seem to work. I have a good dig around the net tonight to see if it is achievable.
 
Thanks edwin, I tried the above but doesnt seem to work. I have a good dig around the net tonight to see if it is achievable.

Can you be more specific? What do you see on the screen? What error message (if any)? I've not tested the above so I may have misplaced a punctuation mark, or similar...
 
<?
echo "<p style=\"font-family: 'Kite One', sans-serif;\">".$domain."</p>";
?>

It's $domainname not $domain

Admin
 
Code:
<head>
<link href='http://fonts.googleapis.com/css?family=Kite+One' rel='stylesheet' type='text/css'>
</head>
<?php
$domainstart = $_SERVER['HTTP_HOST'];
$domainname = str_replace("www.", "", "$domainstart");
echo "<div style=\"font-family: 'Kite One', 'sans-serif';\">".$domainname."</div>";
?>

Full code above, works for me

Admin
 
<p style="font-family: 'Parisienne', serif;\"><font size="7"><? echo "$domainname."; ?></font>
 
yeah cheers admin above is the code that works. Thanks edwin and admin for taking the time to put me on the right track.
 
If you like nice fonts, can thoroughly recommend typekit.com to do a similar job to a higher standard :)
 
going back to the above small script, it dispays the domain name on the website for example thisdomainname.co.uk

can anyone help in having it strip out the extension so it only displays thisdomainname

thanks in advance.
 
The easiest way to remove the extension (since you know it will only be .co.uk/.org.uk etc) would be use str_replace or strtr with an array of known extensions and replace them all with nothing.

The regex to detect and remove all known extensions is a ball ache, so if you know the extensions just replace them.
 
going back to the above small script, it dispays the domain name on the website for example thisdomainname.co.uk

can anyone help in having it strip out the extension so it only displays thisdomainname

thanks in advance.

Assuming you are not on a subdomain (other than www), this script will cater for all domain extensions, without the need for defining and stripping out specific extensions:

Code:
<?php  
$host = str_replace('www.', '', $_SERVER['SERVER_NAME']);
$parts = explode('.', $host);
$domain = $parts[0];

echo $domain;

?>
 
Last edited:
To get around the issue seemly mentioned about www and other subdomains you would try to catch here, again this would only work with 3rd level domains like .*.uk not with .com and such. Always a limitation with simple things :(

Code:
if(sizeof($parts)==2){
$domain = $parts[0];
}else{
$domain = $parts[1];
}

I have found pretty good traffic coming from sub domains, if your host supports wildcard subdomains you should def set that :)
 
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Featured Services

Sedo - it.com Premiums

IT.com

Premium Members

AucDom
UKBackorder
Be a Squirrel
Acorn Domains Merch
MariaBuy Marketplace

New Threads

Domain Forum Friends

Other domain-related communities we can recommend.

Our Mods' Businesses

Perfect
Service
Laskos
*the exceptional businesses of our esteemed moderators
Top Bottom