TinyPortal

Development => Support => Topic started by: hsdk on November 02, 2006, 01:59:39 PM

Title: Add code between articles on frontpage
Post by: hsdk on November 02, 2006, 01:59:39 PM
On my frontpage i only show articles. But i would like to add some php-code between article one and two. In wich file, and where can i add my code? :)

Andreas
Title: Re: Add code between articles on frontpage
Post by: Assistance on November 02, 2006, 02:04:26 PM
make an article with that code then pin it
Title: Re: Add code between articles on frontpage
Post by: hsdk on November 02, 2006, 02:11:49 PM
How do i pin an article to always be number two?
Title: Re: Add code between articles on frontpage
Post by: Assistance on November 02, 2006, 03:24:07 PM
have article 1 pinned, and article 2 set to a less recent date then the middle article

so the article u want in the middle is set to the future
Title: Re: Add code between articles on frontpage
Post by: hsdk on November 02, 2006, 04:17:56 PM
That sounds kind a "stupid"  :), i want my articles to have their appropriate date, and it makes you have to unpin the old and pin a new article every time you write a new one to make it come out on top.

Can anyone point me to where in the source I have to add my own code in such a way that it comes between article one and two? :)


Best Regards
Andreas
Title: Re: Add code between articles on frontpage
Post by: Assistance on November 02, 2006, 04:37:31 PM
sorry if it sounds stupid to you as it did to me aswell

but this the reply I get.............
(note its from Aug, so just imagine how many and often I have to edit articles)

Quote from: Bloc on August 06, 2006, 11:48:08 AM
I see the point though..to make the others appear high up. But with the day/month and present year timespace it should be quite possible to shuffle around.

I have however looked at making articles "sticky" - as in appear AFTER featured (this HAS to be just one article since its tied up against frontpage- show single article option) - sorted on date there as well. So you essentially could sticky thsoe you want high up and just set dates for the positions between them.

I think that will be more versatile in terms of having more than one "featured" article. Its essentially sticky + one super sticky lol. :)
Title: Re: Add code between articles on frontpage
Post by: hsdk on November 02, 2006, 04:45:48 PM
Uhum? So this is like impossible?
Title: Re: Add code between articles on frontpage
Post by: Assistance on November 02, 2006, 04:47:50 PM
i wouldnt say impossible.......... if Tom Cruise can complete a mission

Title: Re: Add code between articles on frontpage
Post by: hsdk on November 02, 2006, 04:50:10 PM
Mayby some hardcore coder, can enlighten us? :)


A
Title: Re: Add code between articles on frontpage
Post by: JPDeni on November 02, 2006, 05:28:08 PM
You could put your featured article into a frontpage article block, followed by your php block (also a front page block) and then follow that other article blocks for the others you want to include. You would change your settings so that you would only show Front Page Blocks on the front page. At that point, you would have complete control over the order that your articles and php appear in.
Title: Re: Add code between articles on frontpage
Post by: hsdk on November 02, 2006, 05:36:23 PM
Yeah, I know that`s one way to solve it, but then i have to reorganize my frontpage every time i write a new article.

Is it reallly impossible to add code where i want? (its a recent topics thingy) :)

Regards A
Title: Re: Add code between articles on frontpage
Post by: JPDeni on November 02, 2006, 05:41:20 PM
It's probably not impossible, but Bloc has said that he is considering making another "sticky" article in a future version, so you could wait for that.

I haven't investigated the innards of all of the code to know where it even prints out the articles.

It's not hard to insert a new block wherever you want to insert it. You only have to change one number to put a block any place you want to in the list.
Title: Re: Add code between articles on frontpage
Post by: hsdk on November 02, 2006, 05:54:30 PM
Quote from: JPDeni on November 02, 2006, 05:41:20 PM
It's probably not impossible, but Bloc has said that he is considering making another "sticky" article in a future version, so you could wait for that.

I haven't investigated the innards of all of the code to know where it even prints out the articles.

It's not hard to insert a new block wherever you want to insert it. You only have to change one number to put a block any place you want to in the list.

I dont use center blocks on my front page, i just show the last 10 articles. And don`t pin any of them.
So, if i should create 10 blocks on my frontpage, and have the mots recent article show up above my recent topics code i will have to move all my articles down one notch. by selecting one and one for each center block.

Or am i not thinking right?

A :)
Title: Re: Add code between articles on frontpage
Post by: JPDeni on November 02, 2006, 06:18:05 PM
QuoteOr am i not thinking right?
Bingo!! :)

If you have blocks, you have something that looks like this:


PosTitle
0Article1
10Article2
20Article3
30Article4

Yes?

So now you want to add Article 5 to the top of the list. It ends up like:

PosTitle
0Article1
10Article5
20Article2
30Article3
40Article4

It always seems to add a new article in the second position. You'd have to change two numbers, I guess, to get it to sort right.


PosTitle
10Article1
0Article5
20Article2
30Article3
40Article4

and hit the Send button, which makes your list end up to be


PosTitle
0Article5
10Article1
20Article2
30Article3
40Article4

Let's say you decide that article 1 needs to be after article 3. Make the changes below:


PosTitle
0Article5
35Article1
20Article2
30Article3
40Article4

Click "Send" and it looks like


PosTitle
0Article5
10Article2
20Article3
30Article1
40Article4

It really is a lot less work than looking through files, altering them, and then having to do it all over again each time a new version comes out, especially if it's in the Source files.
Title: Re: Add code between articles on frontpage
Post by: hsdk on November 02, 2006, 07:37:40 PM
I see, but when i write a new article i manually have to select a block to show it in on the frontpage?

I was kind a hoping not to have to do that. :)

Andreas
Title: Re: Add code between articles on frontpage
Post by: JPDeni on November 02, 2006, 07:44:38 PM
When you create a new article, you would also create a frontpage block to show it in. Would take you maybe a minute if you're on a very slow server. And this would only be temporary. Bloc has said that he'll likely add a feature which will allow you to do what you want in a later version of TP.

I'm not real keen on writing a whole lot of code when there's a way to achieve the same end without writing the code and there's another even easier way coming along later. Just lazy I guess. :)

Editd to add:
You could also just have your sticky article in a block, your php block and another php block that would show the most recent x number of articles.
Title: Re: Add code between articles on frontpage
Post by: hsdk on November 02, 2006, 07:52:47 PM
Okey, I see.

One more thing then. :) If im going to do it this way, i will have to remove the linktree icon that shows on the top of my frontpage. this one -> (https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fwww.hsdk.no%2Fandreas%2Ftestforum%2Fsmf_1-1-rc3_install%2FThemes%2FTP_smFox%2Fimages%2Fnav_inline_start.gif&hash=982b36a5d43f250c8cdd5c5433f599f5925ef524) How could i do this?

See my testsite here: http://www.hsdk.no/andreas/testforum/smf_1-1-rc3_install/index.php

And, THANKS for taking your time to explain this. :)
Title: Re: Add code between articles on frontpage
Post by: JPDeni on November 02, 2006, 08:03:10 PM
In TPortal.template.php, right at the beginning of the file, comment out -- put // at the beginning of -- the following lines:

if((isset($context['TPortal']['boardnews'][0]['options']['linktree']) && $context['TPortal']['front_type']!='frontblock') || $context['TPortal']['front_type']=='frontblock')
echo '
<div style="margin-bottom: 4px;">', theme_linktree() , '</div>';