Jump to content

Article link


Dakrtom
 Share

Recommended Posts

Hello,
I hope someone can help me. After I work with ProcessWire only recently , I wanted to ask if we can someone tell me as 
I a headline on one side with the corresponding article on another page link directly ??

Greeting
Tom
Edited by Dakrtom
line-Break
Link to comment
Share on other sites

 
Hello, thank you for your answer. I try my question to rephrase . 
I would like to create a home ProcessWire be shown on the various articles or posts . 
When I click on the title of the article I müchte I am redirected to the orignal article . 
I hope my question is understandable

Greeting
Tom
Link to comment
Share on other sites

As far as I understand, you want something like a teaser homepage? A collection (in boxes) of subpage summaries with a read-more-link?

If yes, how do you have organized your (sub)pages? Where do they live in the page tree? Do they have different templates? What are the most important fields they have?

Link to comment
Share on other sites

Seems like you want 

10 hours ago, Dakrtom said:
I would like to create a home ProcessWire be shown on the various articles or posts . When I click on the title of the article I müchte I am redirected to the orignal article . I hope my question is understandable Greeting Tom
 

Can you give an example of any website that does what you want? That may help us in answering your question. 

Link to comment
Share on other sites

My guess is that you mean a list of articles with perhaps a summary and then each one links to the full article. You would construct your site to have a child page for each article. Then you can do

foreach($page->children("limit=10, sort=-published_date") as $article) {
	echo "<a href='$article->url'>$article->title<\a>$article->summary";
}

That will display titles and summaries of the last 10 articles with direct links to the page where the full article lives.

Apologies for the brevity and code formatting - not a good idea to try this on a phone while your laptop is running updates :)

 

  • Like 1
Link to comment
Share on other sites

The code I gave you does pretty much that assuming you have a separate field for the teaser (I called it summary). If you want an automatic teaser than you need to truncate the body field (or whatever you might have called it). Instead of $article->summary, you can try something like:

substr($article->body, 0, 300)

Of course you can get much fancier with automatic teasers, but that is a PHP question and there are lots of answers on the web about that.

Also, if you want the code I had to work from the homepage while the articles are perhaps under an Articles child of home, then try this:

foreach($pages->get("/articles/")->children("limit=10, sort=-published_date") as $article) {
	echo "<a href='$article->url'>$article->title<\a>".substr($article->body, 0, 300);
}
  • Like 1
Link to comment
Share on other sites

3 hours ago, Dakrtom said:

Hello,
many thanks for the code , yesterday equal yet tried it and works great but a 
question I have to . how I do it that I and summary with html and css can edit Title : here an example :

<P > title </ p>
<P > summary </ p>

I am sorry @Dakrtom - now you have completely lost me :)

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...