Recent Topics

1 Apr 23, 2009 04:09    

My b2evolution Version: Not Entered

How can i retrieve the current url of a post/page-post/post and get it displayed within a b2 install ?

is there a global method to do it ?

or should i retrieve each items url seperately, theorically;

if type is post : .$Item->get_permanent_url(),
if is page-post,
if is actual page(like index.php, sitemap.php, summary.php etc) ,?? i mean it's just like dragging the current url from the adress bar, hope i could make it clear

2 Apr 23, 2009 04:37

regenerate_url() is probably your new best friend. An example of it in action is on the contact page where, I guess, it asks if you want to send another message. Seems I don't actually have a contact page so I can't be sure of that, but the code in contact.php goes like this:

echo '<p><a href="'.regenerate_url().'">'.T_('Send another message?').'</a></p>';

It's got lots of parameters you can do stuff with but I don't really know what they do. I'm pretty sure though that just using it works pretty slick.

3 Apr 23, 2009 05:02

great!! now i gotta find a way to alter/limit the parameters to it..

for example it converts:
A post:

PostURL

to:

PostURL?disp=single&title=lorem-ipsum-dolor-sit-amet&more=1&c=1&tb=1&pb=1

A page:

PagepostURL

to:

PagepostURL?disp=page&title=about-this-system&more=1&c=1&tb=1&pb=1

the above ones are working, though i dont want the unnecessary '?disp=&title=&more=1&c=1&tb=1&pb=1' extensions.

---------------------------------

an exception

Contact form:

http://localhost/b3/blog1.php?disp=msgform&recipient_id=1&redirect_to=http%3A%2F%2Flocalhost%2Fb3%2Fblog1.php%3Fdisp%3Dmsgform

to:

http://localhost/b3/blog1.php?disp=msgform

where this is not working as the recipient is not identified but it's not an important exception

i have dugg through docs but no luck yet.. i hope someone may give a hand

4 Apr 23, 2009 05:15

So do you mean you are getting the actual URL PLUS all the bitsy stuff? In other words, when you say

PostURL?disp=single&title=lorem-ipsum-dolor-sit-amet&more=1&c=1&tb=1&pb=1

does the

PostURL

part actually have the right amount to be a link?

The thing is one of the parameters you can feed that thing is $ignore, which seems to be (potentially) a list of params you can tell it to ignore. So MAYBE something like this might be worth a shot:

<a href="'.regenerate_url( 'more,c,tb,pb' ).'">'.T_('Does this look good and work right?').'</a>

If all goes really well that'll knock the &more=1&c=1&tb=1&pb=1 glunk off the end. Dunno though. You might soon though eh?

5 Apr 23, 2009 05:52

EdB wrote:

So do you mean you are getting the actual URL PLUS all the bitsy stuff? In other words, when you say

PostURL?disp=single&title=lorem-ipsum-dolor-sit-amet&more=1&c=1&tb=1&pb=1

does the

PostURL

part actually have the right amount to be a link?

yep, that is an actual link, just used that phrase to shorten it.

EdB wrote:

The thing is one of the parameters you can feed that thing is $ignore, which seems to be (potentially) a list of params you can tell it to ignore. So MAYBE something like this might be worth a shot:

<a href="'.regenerate_url( 'more,c,tb,pb' ).'">'.T_('Does this look good and work right?').'</a>

If all goes really well that'll knock the &more=1&c=1&tb=1&pb=1 glunk off the end. Dunno though. You might soon though eh?

trying right away

edit: yay, it seems it worked thanks a billion

6 Apr 23, 2009 06:21

// Generate 'clean' current URL
function clean_current_url( $rem = NULL, $set = NULL )
{
	global $disp;
	
	$ignore = 'blog,cat,order,orderby,title,more,c,tb,pb,locale';
	if( !empty($rem) ) $ignore .= ','.$rem;
	
	switch( $disp )
	{	// Remove 'disp'
		case 'single':
		case 'page':
			$ignore .= ',disp';
			break;
	}		
	return regenerate_url( $ignore, $set );
}

;)

7 Apr 23, 2009 06:41

sam2kb wrote:

// Generate 'clean' current URL
function clean_current_url( $rem = NULL, $set = NULL )
{
	global $disp;
	
	$ignore = 'blog,cat,order,orderby,title,more,c,tb,pb,locale';
	if( !empty($rem) ) $ignore .= ','.$rem;
	
	switch( $disp )
	{	// Remove 'disp'
		case 'single':
		case 'page':
			$ignore .= ',disp';
			break;
	}		
	return regenerate_url( $ignore, $set );
}

;)

cool...i wonder if it could get any better B) thanks to both, much appreciated

8 Apr 23, 2009 06:42

As a hack? Like, for hacks.php?

9 Apr 23, 2009 06:49

dunno, i ll just include it directly, i dont think i ll use hacks.php, i never did actually, have no idea how it works and what's the use

10 Apr 23, 2009 14:43

BTW you must also check if 'clean urls' are enabled in current blog. I use this function in my blog so I sure about 'clean urls'.

If you delete all params from URLs and 'clean urls' are disabled you'll get in troubles :)

11 Apr 23, 2009 20:24

tilqicom wrote:

dunno, i ll just include it directly, i dont think i ll use hacks.php, i never did actually, have no idea how it works and what's the use

In a skin? For public use? Generally speaking I think it's kinda 'not the way' to have functions in skins. Yeah it'll work and all, but I'm pretty sure it would be the exception.

Like sam2kb says, lots of different configs means - IF it is for public use - you gotta be extra sure it'll work across all possible combinations of everything. Much better to call core functions then yah? Unless it is for personal use. If so then you know full well it'll work if you see it work :)

hacks.php is cool. Ever since forever b2evolution will read the file if it exists, so that's how you get to add extra functions to "the core" without actually hacking the core. Plus since it isn't part of the core it'll never be wiped out when you upgrade. Drawback is with everything being classes and objects and thises and thats I've no idea how to make it work for lots of stuff anymore. Awww :( On the plus side, it wipes out footer spam :D

12 Apr 23, 2009 20:34

You can kill the rest of the spyeware by slapping a huge futuristic date in the settings for "next_update" ;)

¥

13 Apr 23, 2009 20:41

Nice idea. Hadn't thought of it. Recently I wiped out the entire function. Not just a 'return' - completely wiped it out. Pure junk. I use the feed from the news blog to know what I need to know eh?

Back on track: I was thinking just now "isn't there probably a way to get the item's permalink without resorting to regenerate_url()" ? Something like, oh I dunno, $Item->permanent_link() ? Dunno all the bits that can be fed into the array it likes, but surely that'd be easier and betterer than either method available here so far. ASSUMING this is for a skin of course.

EDIT:

$Item->permanent_link( array(
	'before'      => '',
	'after'       => '',
	'text'        => '#',    // possible special values: '#', '#icon#', '#text#', '#title#'
	'title'       => '#',
	'class'       => '',
	) );

Not sure what # and # default to, but if you want to follow the trail to the source dig on this: http://doc.b2evolution.net/v-2-4/evocore/ItemLight.html#methodpermanent_link then http://doc.b2evolution.net/v-2-4/__filesource/fsource_evocore__blogsincitemsmodel_itemlight.class.php.html#a673 then http://doc.b2evolution.net/v-2-4/evocore/ItemLight.html#methodget_permanent_link then http://doc.b2evolution.net/v-2-4/__filesource/fsource_evocore__blogsincitemsmodel_itemlight.class.php.html#a628 so maybe it ain't so hard. If 'text' is '#' you will get an icon with the word "permalink". If 'title' is '#' you will get "Permanent link to full entry" as the mouseover text.

14 Apr 23, 2009 20:46

Or :

golobal $ReqURI;
echo <a href="'.$ReqURI.'" title="here">http://mydomain.com/some-page/</a>';

¥

15 Apr 23, 2009 20:52

Or trust a guy who gives one-word answers to have it in one word :)

16 Apr 23, 2009 20:57

Would look better if it wasn't free-typed :P

global $ReqURI;
echo '<a href="'.$ReqURI.'" title="here">http://mydomain.com/some-page/</a>';

¥

17 Apr 23, 2009 21:06

yeah that's right after all. Thought it wasn't, posted, realized, deleted, figured deleting ain't cool, so now this. Makes no sense. Need either coffee or nature's finest herbal supplement. Got coffee, so there you go.

18 Apr 23, 2009 21:09

I know you'll appreciate that I don't have coffee ;)

¥


Form is loading...