In my recent post: Google AdSense Now Logs Into Your Sites I mentioned that displaying a quick preview of your content might be useful in some scenarios. U mojim nedavnim post: Google AdSense Sada se prijavljuje na Vašim stranicama sam spomenuo da prikazujete brzi pregled svog sadržaja mogu biti korisni u nekim scenarijima. Particularly if you want to charge subscription fees for full content. I’ll illustrated with an example so you can get an idea of where to start in accomplishing this with your own sites. Osobito ako želite naplaćivati pretplata naknada za cijeli sadržaj. Ja ću se vidi na primjer tako možete dobiti ideju gdje bi početi u ostvarenju ove sa svoje vlastite web lokacije. The key component in making this work is the substr ($content,0,300) function. Ključna komponenta u izradi ovog rada je substr ($ sadržaj, 0300) funkciju. You specify the length of content by declaring a start (0) and the end (300). Vi određujete trajanje sadržaja progla početak (0) i kraju (300). You can then output a shortened version of $content and store it in a separate variable. Možete onda izlaz skraćenu verziju $ sadržaja i spremiti u zasebnu varijablu. Great to use as a “preview” for your content. Odlično za upotrebu kao "preview" za Vaš sadržaj. Note: the number refers to the numbers of characters in the provided string, not words. Napomena: broj odnosi se na broj znakova u dobivenom string, a ne riječi.

What you need to do is figure out the existing variables you’re outputting on each content page (likely found within your template). Što trebate učiniti je lik iz postojećih varijabli ste outputting na svakoj stranici sadržaja (vjerojatno našao unutar vašeg predloška). This part goes beyond the scope of this article. Ovaj dio ide van dosega ovog članka. All sites are set up with slightly differently variables and even grab content from different sources…this is not an exact science. Sve web stranice su postavili s malo drugačije varijable, pa čak i hvataljka sadržaja iz različitih izvora ... ovo nije točno znanosti.

I will assume your data is coming from a mySQL database and $id is a number that refers to a row of content in your database. Pretpostaviti ja ću se Vaši podaci dolaze iz MySQL baze podataka i $ id je broj koji se odnosi na niz sadržaja u bazu podataka. This first snippet shows a row being queried in preparation for it to be cut down into a preview. Ovaj prvi odlomak pokazuje queried redom se u pripremi za to treba smanjiti na pregled.

  1. $result = mysql_query ( "SELECT id,content FROM table WHERE id={$id}" , $db ) ;
  2. $row = mysql_fetch_row ( $result ) ;
  3. echo $row [ 0 ] ; //The value of id
  4. echo $row [ 1 ] ; //The value of content
  5. $content = $row [ 1 ] ; //Store it into something we can identify easily

This is even easier when you already have your content in a string. To je čak lakše kad već imate svoj sadržaj u niz. In that case you wouldn’t have to run a query on it again. U tom slučaju ti ne bi za pokretanje upita na nju ponovno. There are also applications in which you would want to have this preview show before you content. Tu su i programi u kojima biste željeli imati ovaj pregled prikazati prije nego što sadržaja. In that case you would only need to integrate something like this into your templates (and yes there is more then one way to do this): U tom slučaju ti bi samo potrebu za integriranjem nešto poput ovog u vaše predloške (i da ima više od jedan način za to):

  1. $previewcontent = substr ( $content , 0 , 300 ) ;
  2. if ( isset ( $go ) ) { //If set then they have seen the preview already
  3. echo $content ; //Display your usual content
  4. } else { //First time viewing this page
  5. echo "Article preview:<br><br>" . $previewcontent ;
  6. echo "See this entire post<a href= \" showcontent.php?id=" . $id . "&go=yes \" >here</a>" ;
  7. //Or you could add something like this (instead of lines 6 & 7) for paid/subscription content
  8. if ( isset ( $user ) ) { //If a user is logged in…
  9. echo "Go ahead and <a href= \" showcontent.php?id=" . $id . "&go=yes \" >view</a>" ;
  10. } else { //$user is not set - insert login/signup link/form below
  11. echo "To view this solution please click <a href= \" yoursignupscript.php \" >here</a> to purchase access." ;
  12. }

In my alternate configuration where visitors need to purchase access you should also change your first if statement to check if a user is logged in by doing: U mom izmjenični konfiguraciji, gdje posjetitelji morati kupiti pristup morate promijeniti svoj prvi ček ako izjavi da ako je korisnik prijavljen u tako što:
if(isset($go) && isset($user)) if (isset ($ kreni) & & isset ($ korisnik))

There’s some security and usability you need to consider when implementing this which I didn’t get into. Postoji nekoliko sigurnosti i upotrebljivosti morate uzeti u obzir prilikom implementacije ovoga što nisam ući. As shown above isset () is another very handy function in php as it allows you to set triggers in conjunction with if statements. Kao što je prikazano gore isset () je još jedan vrlo zgodan funkcija u php kao što vam omogućuje da postavite aktivira ako u vezi sa izvještajima. This can make a webpage very dynamic. To se može napraviti web stranicu vrlo dinamičan.

If you’re not that far yet with a coding language, I hope this at least gives you some ideas of what you can do. For additional help check out php.net: http://us3.php.net/substr . Ako Vam se ne da još daleko sa kodiranje jezik, nadam se ovaj barem daje vam neke ideje što možete raditi. Za dodatnu pomoć odjaviti php.net: http://us3.php.net/substr. Just getting started with php/mySQL?: Increase Earning Potential With These PHP/mySQL Tutorials Dovoljno je početak sa PHP / MySQL?: Povećanje zaradom Potencijalni s ovim PHP / MySQL Tutorials



Leave A Comment: Ostavi komentar:

Comments RSS Feed Komentari RSS Feed

5 Plus 3 = 5 plus 3 =

Custom Theme by Rob Malon | Content & Design © 2008 - Rob Malon [dot] Com. Custom Theme by Rob Malon | Sadržaj & Design © 2008 - Rob Malon [dot] com. "));
"));