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. 귀하의 사이트에 내 최근 게시물에서 그 콘텐츠의 빠른 미리보기를 표시하는 몇 가지 시나리오에서 유용할 수있습니다 언급 : 구글 애드 센스 지금 로그. 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 ) ; ID를 $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. $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 ;
  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 & //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: 내 대체 구성에서는 방문자들이 어디에서 뭘하고있는 경우 사용자에 의해 기록됩니다 당신은 당신의 진술을 확인하는 경우 가장 먼저 변경해야 액세스를 구매할 필요 :
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에서 다른 매우 편리한 기능과 함께 표시되는 진술을 유발하는 경우. This can make a webpage very dynamic. 이것은 매우 역동적인 웹페이지를 만들 수있습니다.

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 피드

7 Added To 2 = 7 대 2로 = 추가됨

Custom Theme by Rob Malon | Content & Design © 2008 - Rob Malon [dot] Com. 맞춤 테마 롭 런에 의해 | 콘텐츠 & 디자인 © 2008 - 롭 메일런 [도트] 그럼요. "));
"));