Membership is FREE, giving all registered users unlimited access to every Acorn Domains feature, resource, and tool! Optional membership upgrades unlock exclusive benefits like profile signatures with links, banner placements, appearances in the weekly newsletter, and much more - customized to your membership level!

landing page to use google fonts.

Status
Not open for further replies.

Paullas

Staff member
Joined
Jul 13, 2004
Posts
5,830
Reaction score
375
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...
 
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.
 
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!

Members online

Premium Members

New Threads

Domain Forum Friends

Our Mods' Businesses

*the exceptional businesses of our esteemed moderators
General chit-chat
Help Users
  • No one is chatting at the moment.
      There are no messages in the current room.
      Top Bottom