2 edb Apr 23, 2009 04:37

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:
to:
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
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?
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
// 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 );
}
;)
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
As a hack? Like, for hacks.php?
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
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 :)
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
You can kill the rest of the spyeware by slapping a huge futuristic date in the settings for "next_update" ;)
¥
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.
Or :
golobal $ReqURI;
echo <a href="'.$ReqURI.'" title="here">http://mydomain.com/some-page/</a>';
¥
Or trust a guy who gives one-word answers to have it in one word :)
Would look better if it wasn't free-typed :P
global $ReqURI;
echo '<a href="'.$ReqURI.'" title="here">http://mydomain.com/some-page/</a>';
¥
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.
I know you'll appreciate that I don't have coffee ;)
¥
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:
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.