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.あなたのサイトに私の最近の記事で私は、お客様のコンテンツを簡単にプレビューを表示するいくつかのシナリオに有用である可能性があります言及: Google AdSenseの今ログ。 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.特にすべてのコンテンツを購読する場合の手数料をしたいのですので、ここで自分のサイトでこの達成に開始するのは、アイデアを得ることができます私は例で示されます。 The key component in making this work is the substr ($content,0,300) function.この作品は、 substr ( $コンテンツ、 0300 )関数であることで重要なコンポーネントです。 You specify the length of content by declaring a start (0) and the end (300).あなたが開始( 0 )と最後( 300 )宣言して、コンテンツの長さを指定します。 You can then output a shortened version of $content and store it in a separate variable.出力ドルの短縮版をすることができますし、コンテンツとは別の変数に格納します。 Great to use as a “preview” for your content.偉大なお客様のコンテンツのための"プレビュー"として使用する。 Note: the number refers to the numbers of characters in the provided string, not words.注:番号が提供する文字列中の文字の数字ではなく、言葉を指します。

What you need to do is figure out the existing variables you’re outputting on each content page (likely found within your template).を行うための各コンテンツページに出力して、既存の変数を理解するには、どのよう必要があります(そう、テンプレート内の)を発見した。 This part goes beyond the scope of this article.この部分は、この資料の範囲を超えている。 All sites are set up with slightly differently variables and even grab content from different sources…this is not an exact science.すべてのサイトが若干異なる変数とも異なるソースからのコンテンツをつかむに設定されている...これは正確な科学ではない。

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.私は、 MySQLデータベースからデータを想定して来ていると$ IDは、コンテンツのデータベース内の行を参照する番号です。 This first snippet shows a row being queried in preparation for it to be cut down into a preview.この最初のスニペットを減らすためにプレビューするに照会されてから準備中の行が表示されます。

  1. $result = mysql_query ( "SELECT id,content FROM table WHERE id={$id}" , $db ) ; アイダホのSELECT $result = mysql_query ( "SELECT id,content FROM table WHERE id={$id}" , $db ) ;アイダホ $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 / / 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.このときでも、すでにお客様のコンテンツが文字列に簡単です。 In that case you wouldn’t have to run a query on it again.この場合、もう一度上のクエリを実行する必要がないと思います。 There are also applications in which you would want to have this preview show before you content.また、あなたは、このプレビューを表示する前に、コンテンツが欲しいとアプリケーションです。 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):この場合、このようなお客様のテンプレートのみに何かを統合する必要があります(とイエスがこれを行うにして1つの方法です) :

  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 表示 echo $content ; //Display your usual content
  4. } else { //First time viewing this page
  5. echo "Article preview:<br><br>" . $previewcontent ; エコー 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 6 //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… / 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." ; < 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:私の別の構成ではここを訪れる場合は、ユーザーでログオンしていることが確認したい場合には、 if文を最初に変更する必要がありますアクセスを購入する必要があります:
if(isset($go) && isset($user)) (調べるisset ( $行く) & &調べるisset ( $ユーザ) )

There’s some security and usability you need to consider when implementing this which I didn’t get into.いくつかのセキュリティおよび使いやすされたとき、この私には得られなかったの実施を検討する必要があります。 As shown above isset () is another very handy function in php as it allows you to set triggers in conjunction with if statements.これを設定することができます上記のように調べるisset ( )はPHPで非常に便利な機能を示す別のif文と一緒にトリガされます。 This can make a webpage very dynamic.これは非常に動的なWebページを作ることができます。

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 .もしそこまではまだしていない言語でコーディング、僕は少なくともあなたが何ができるのいくつかのアイデアを、この期待している。を追加支援の確認php.net : http://us3.php.net/substr Just getting started with php/mySQL?: Increase Earning Potential With These PHP/mySQL TutorialsはPHPのスタートアップムービー/のmySQLのか: PHPでこれらの増加獲得の可能性/のmySQLチュートリアル



Leave A Comment:コメントを残す:

Comments RSS Feed コメントのRSSフィード

8 1 = 8 1 =

Custom Theme by Rob Malon | Content & Design © 2008 - Rob Malon [dot] Com. カスタムテーマロブマロン|コンテンツ&デザイン© 2008 -ロブマロン[ドット]コム。 "));
"));